I am pretty new to Flutter and I am trying to build an App based on GoogleMaps. Now I added multiple markers and when you tap them the first time a info window pops up. Then, after tapping the info window, I want to change route to another screen, which then includes the description of the place etc. However, I am struggling now with making it possible to change route after tapping the infowindow, meaning nothing happens when I tap it.
Is it possible to use the 'OnTap' function on the infowindow? I'm happy for any solutions.
My current code for the marker section:
markers.add(Marker( //add first marker
markerId: MarkerId(showLocation.toString()),
position: showLocation, //position of marker
infoWindow: InfoWindow( //popup info
title: 'Marker Title First ',
snippet: 'My Custom Subtitle',
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SecondScreen()),
);
},
),
icon: BitmapDescriptor.defaultMarker, //Icon for Marker
));
I just found a supposedly working solution on this problem (Problem with google_maps_flutter, marker onTap(){} doesn't work), however, I guess due to the implementation of null safety it is not working anymore, since I had to initialize the field 'BuildContext'. I did so using 'late' before it, but it still does not work.
We found the problem, I have given multiple markers the same MarkerId. After I changed it, it worked fine. Sorry guys, case closed!