onMapCreated: (controller) => _googleMapController = controller,
Invalid constant value.
how can i fix that ?
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
class MapScreen extends StatefulWidget {
@override
State<MapScreen> createState() => _MapScreenState();
}
class _MapScreenState extends State<MapScreen> {
static const _initialCameraPosition = CameraPosition(
target: LatLng(36.71228369662267, 3.1805848553156153),
zoom: 16.5,
);
GoogleMapController? _googleMapController;
@override
void dispose() {
_googleMapController?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return const Scaffold(
body: GoogleMap(
myLocationButtonEnabled: false,
zoomControlsEnabled: false,
initialCameraPosition: _initialCameraPosition,
onMapCreated: (controller) => _googleMapController = controller,
),
);
}
}
1-went to the documentation and executed test code. same issue
2-google similar problems , but it didnt help
3- chat gpt and no help as well
>Solution :
I think you need to remove the const before Scaffold( …