flutter_animarker
flutter_animarker copied to clipboard
Unhandled Exception: Unknown marker ID "99" in InfoWindow onTap in Animarker
This is my animarker code
It works when I set marker in Google Map but I need marker in animarker widget
Hello did you figure this out?
Hello, same problem An issue on this topic has already been opened and closed without being answered or corrected.
The only (very bad) "solution" is to duplicate the markers set and assign it to GoogleMap's "marker:" but this causes a duplication of the markers on the map, those animated by Animarker and the static ones from GoogleMap, so they're all duplicated. Even by forcing the visibility of GoogleMap markers to false and setting an invisible icon, GoogleMap markers are still present and unchanged.
A solution is urgently needed, because as soon as you define a marker in Animarker and tap on it, the application crashes with the error "UnknownMapObjectIdError (Unknown marker ID "00001" in onTap)".
Thanks.
I managed to work around the problem by patching a file in the google_maps_flutter package. The idea is to secure the onMarkerTap method while avoiding sending the exception. I thought I'd also have to modify the onInfoWindowTap method, but after testing, I've found that this isn't necessary. Tested on versions 3.2.0 and 3.4.0-beta.1 The file to be modified is : AppData\Local\Pub\Cache\hosted\pub.dev\google_maps_flutter-2.5.2\lib\src\google_map.dart So here's original and patched code:
// ----- PATCH TO AVOID INDEX EXCEPTION WHEN USE WITH FLUTTER_ANIMARKER -----
// ----- ORIGINAL VERSION :
// void onMarkerTap(MarkerId markerId) {
// final Marker? marker = _markers[markerId];
// if (marker == null) {
// throw UnknownMapObjectIdError('marker', markerId, 'onTap');
// }
// final VoidCallback? onTap = marker.onTap;
// if (onTap != null) {
// onTap();
// }
// }
// ----- PATCH TO AVOID INDEX EXCEPTION WHEN USE WITH FLUTTER_ANIMARKER -----
// ----- PATCHED VERSION :
void onMarkerTap(MarkerId markerId) {
final Marker? marker = _markers[markerId];
if (marker != null) {
final VoidCallback? onTap = marker.onTap;
if (onTap != null) {
onTap();
}
}
}