PopupState.of() called in a context with no PopupState
PlaxXOnline opened this issue · 2 comments
PlaxXOnline commented
Hello everyone,
I wanted to update one of my very first Applications with flutter_map and flutter_map_marker_cluster and so i did.
Now i ran into an error i don´t really understood because i don´t find anything about the popups.
I also looked into the flutter_map_marker_popup Repository but also there was nothing to find espacially about the popupState..
This is the Bad State Error:
Bad state: 'PopupState.of()' called in a context with no PopupState. Consider using PopupScope to add a PopupState to the context
Here is my Code:
MarkerClusterLayerWidget(
options: MarkerClusterLayerOptions(
maxClusterRadius: 120,
size: const Size(40, 40),
padding: const EdgeInsets.all(50),
markers: markers,
polygonOptions: const PolygonOptions(
borderColor: Colors.blueAccent,
color: Colors.black12,
borderStrokeWidth: 3),
popupOptions: PopupOptions(
popupSnap: PopupSnap.markerTop,
popupController: popupController,
popupBuilder: (_, marker) {
final facilityMarker = marker as FacilityMarker;
return InfoPopup(size: size, locale: locale, facilityMarker: facilityMarker);
}),
builder: (context, markers) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
color: Colors.blue),
child: Center(
child: Text(
markers.length.toString(),
style: const TextStyle(color: Colors.white),
),
),
);
},
),
),
jfmlima commented
Try wrapping your FlutterMap in a PopupScope and see if that helps 👍 (Don't forget to pass the PopupController and propagate it to the popupOptions)
PlaxXOnline commented
That worked! Thank you!