I'm trying to finding a way to access to flutter_map controller from outside the class the idea is that i have markers on the map screen . when you tap on the marker the map should move so that spicefic marker be on the middle
the Problem that the marker class Initial in different class so i can not access to map control immediately
how can i make the map move ?
./screens/homeScreen.dart
class HomeScreen extends StatefulWidget {
static const routeName = '/home';
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
Widget build(BuildContext context) {
return Scaffold(
body:FlutterMap(
mapController: _mapController,
MarkerClusterLayerOptions(
onMarkerTap: (_) {
}, // Cluster tab
markers:externalReports.items // get the markers list
centerMarkerOnClick: true, // Cluster center
....),);}}
./externalReports.dart // where The Items Initial
_items.add(
Marker(
optionalDataContainer: data,
width: 45.0,
height: 45.0,
point: LatLng(
latitude,
longitude,),
builder: (context) => Container(
child: Container(
height: 45,
width: 45,
child: GestureDetector(
onTap: () {
// _mapController.move(LatLng(latitude,longitude), 15.0);
}))))