Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'Client' in type cast in flutter?

I want to get the Client name from the Api using fromMap() method as shown bellow:

factory Order.fromMap(Map<String, dynamic> map) {
  return Order(
   created_at: Tracker.decode(map['created_at']),
   id: map['id'],
   updated_at: Tracker.decode(map['updated_at']),
   total_price: map['total_price'],
   status: map['status'],
   client: map['client']


  );
 }

client is an object of Client Model ..
I got the following error:
type ‘_InternalLinkedHashMap<String, dynamic>’ is not a subtype of type ‘Client’ in type cast…

thank you for your help!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You are trying to assign a data of type Map<String, dynamic> to the client which seems to the of type Client.

You need to convert the map['client'] into the Client by using Client.fromMap(map['client']) assuming you have the Client model

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading