Reputation: 11
I'm new to flutter so this question sounds like foolish but I really want this meaning.
class MapSample extends StatefulWidget {
@override
State<MapSample> createState() => MapSampleState();
}
class MapSampleState extends State<MapSample> {
Completer<GoogleMapController> _controller = Completer();
...
@override
Widget build(BuildContext context) {
return new Scaffold(
body: GoogleMap(
mapType: MapType.hybrid,
initialCameraPosition: _kGooglePlex,
onMapCreated: (controller) {
_controller.complete(controller);
},
),);
}
Upvotes: 0
Views: 1095
Reputation: 531
1: onMapCreated is a function that takes a mapController and optional parameter called options. The option is used to change the UI of the map such as rotation gestures, zoom gestures, map type, etc. The function of mapController is mostly similar to TextEditingController as it is being used to manage the camera functions, zoom and animations, etc.
2: As mentioned above mapController takes parameters to change the functions of the map such as changing position, zoom, etc.
3: The difference between controller and _controller is that _controller is private to the class where it is declared and can not be accessed outside of it. It is the same concept of private and public variables.
Upvotes: 3