class _HomeScreenState extends State<HomeScreen> {
GoogleMapController? mapController; // 3
Widget build(BuildContext context) {
return Column(
body: _CustomGoogleMap(
onMapCreated: onMapCreated, // 5
),
)
}
}
onMapCreated(GoogleMapController controller) { // 4
mapController = controller;
Se}
// stless widget
class _CustomGoogleMap extends StatelessWidget {
final MapCreatedCallback onMapCreated; // 2
const _CustomGoogleMap({
required this.onMapCreated, // 2
Key? key,
}) : super(key: key);
Widget build(BuildContext context) {
return GoogleMap(
onMapCreated: onMapCreated, // 1
)
}
}
Dart
복사
1.
recieve controller as a parameter
2.
define the controller by its type
3.
define the contoller on state // to manage variables from state
4.
recieve the controller and pass it to the no.3
5.
use it on the variable
