How to deal with type mismatch between LatLng classes?

Custom Code

In my custom widget I get the error below.

I think it is because I have two LatLng classes:

  • Flutterflow

  • Google Maps package

lib/custom_code/widgets/google_map.dart:22:1: Error: 'LatLng' is imported from both 'package:google_maps_flutter_platform_interface/src/types/location.dart' and 'package:proximity_map_w_ith_niral/flutter_flow/lat_lng.dart'.
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';

ChatGPT says:


It seems like you're encountering a type mismatch error between two different LatLng classes.

The error message indicates that there's a conflict between the LatLng class from two different packages:

LatLng from package:google_maps_flutter_platform_interface/src/types/location.dart
LatLng from package:proximity_map_w_ith_niral/flutter_flow/lat_lng.dart
To resolve this issue, you need to ensure that you're consistently using the correct LatLng class throughout your code. If you intend to work with the LatLng class from the google_maps_flutter package, make sure you import it and use it consistently.

So, I can't remove the FlutterFlow definition.

And I need the Google Maps package for other classes used in this widget.

Does anyone have suggestions how to resolve this?

What have you tried so far?

Asked ChatGTP

Did you check FlutterFlow's Documentation for this topic?
Yes
4 replies