a14n / dart-google-maps

A library to use Google Maps JavaScript API v3 from Dart scripts.
Apache License 2.0
130 stars 66 forks source link

Definition of Map in version 8.0 conflicts with Dart's abstract interface class Map<K, V> #141

Closed jozes closed 1 month ago

jozes commented 1 month ago

Hello! I tried to upgrade from version 6.2 to latest version 8.1.1 and found that new definition of Google Map in version 8 conflicts with Dart's abstract interface class Map<K,V>.

I know that I can import google_maps package under different name but I don't see this as nice solution as I have to change a lot of code. I am surprised that GMap was renamed to Map which is used as generic class in Dart and thus causing a lot of problems. It would be much easier if GMap would be renamed to GMap2 or another keyword if it was sensible to rename it to resolve conflicts wit older versions.

In the code I am using Dart Map in many places especially when I need to define the type of Map like Map<String, dynamic>.

Any good idea what to do? I bet I am not he only one using Dart abstract interface class Map<K,V> together with Goggle Maps package.

Thanks for your suggestions.

Regards, Joze

a14n commented 1 month ago

8.0.0 is a complete rewrite of the lib using a generator based on GoogleMaps documentation. That's why GMap became Map. Even if I tried to limit the actions to be done to migrate to 8.0.0 it was not possible to avoid them.

In your case you can update import:

-import "package:google_maps/google_maps.dart";
+import "package:google_maps/google_maps.dart" hide Map;
+import "package:google_maps/google_maps.dart" as gmaps show Map;

and replace GMap by gmaps.Map.

jozes commented 1 month ago

@a14n Wow, that was really fast response, thank you so much for that. Will follow your advice :-) I was just wondering why this happened.

I would like to suggest you that you put a short notice regarding the migration from older versions in the readme file as these instructions would be very beneficial for other users. I expect that there will some more developers who will encounter this problem and if it would be mentioned in the readme it would save them quite a lot of time.

Thanks once again! Joze

jozes commented 1 month ago

Problem resolved!