I'm trying to make a Flutter app, using Riverpod for state management and FlutterMaps. I have set up notifiers for pages, and am also using a (State)NotifierProvider for the map page. I am building a search function, which goes to a search page which displays a list with search results. When one of these results (in a list) is clicked, I update the notifier of the map page. However, here comes the tricky part: I want to update the map according to the LatLng of the search result (center it).
My implementation of the Notifier contains:
late MapController? _mapController;
My map page is loaded in and gets the mapController from the Notifier: mapController: notifier.getMapController()
Using Riverpod state management, this all should work, however I get the following Error:
LateError (LateInitializationError: Field '_state@1225051772' has already been initialized.)
This Error is within the MapController itself (which is part of the FlutterMaps package), so I do not want to touch that. Does anyone have any idea how to tackle this?