1
      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."

1
  • You have to create a LatLng from your json, atLng: LatLng(json['latLng']['lat'], json['latLng']['lng'] ) , Commented Apr 25, 2022 at 8:13

1 Answer 1

1

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']),
1
  • In my case it was json['latLng']['geopoint'].latitude, json['latLng']['geopoint'].longitude. Commented Apr 25, 2022 at 8:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.