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

Flutter – Get LatLong from json

      factory FieldModel.fromJson(String fieldId, Map<dynamic, dynamic> json) =>
      FieldModel(
        fieldId: fieldId,
        ownerId: json['ownerId'],
        name: json['name'],
        imageUrl: json['imageUrl'],

        ///how to extract this, its a LatLng class from "google_maps_flutter_platform_interface/src/types/location.dart"
        latLng: json['latLng'],
        description: json['description'],
        charges: json['charges'],
        timeSlots: json['timeSlots'],
        availability: json['availability'],
      );

Error: "type ‘_InternalLinkedHashMap<String, dynamic>’ is not a subtype of LatLng."

>Solution :

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

Let’s say your json looks like this,

... 
"latLng": {"lat": 1234.121, "lng": 958.1232}
...

You will have to use your latLng value to create a LatLng object,

latLng: LatLng(json['latLng']['lat'], json['latLng']['lng']),
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