onTap: () async {
final GoogleMapController controller = await _controller.future;
var lat = double.tryParse("-$detailCampus['latitude']")!;
var long = double.tryParse("$detailCampus['longitude']")!;
controller.animateCamera(
CameraUpdate.newCameraPosition(
CameraPosition(target: LatLng(lat, long), zoom: 18, tilt: 50, bearing: 45),
),
);
},
my code has an error, i want to take latitude and longitude from my database. but i had problem double need null checker when i try to use null checker like this
var lat = double.tryParse("-$detailCampus['latitude']")!;
var long = double.tryParse("$detailCampus['longitude']")!;
then i try this one
CameraPosition(target: LatLng(lat!, long!), zoom: 18, tilt: 50, bearing: 45),
but still error.
CodePudding user response:
Try this:
var lat = double.tryParse("-${detailCampus['latitude']}") ?? 0;
var long = double.tryParse("${detailCampus['longitude']}") ?? 0;
Then
CameraPosition(target: LatLng(lat, long), zoom: 18, tilt: 50, bearing: 45),