I have this error quite a bit in my code and I don't know how to fix it. I have read many answers, but none of them solve it?
if (event.snapshot.value["car_details"] != null) {
setState(() {
carDetailsDriver = event.snapshot.value["car_details"].toString();
});
}
if (event.snapshot.value["driver_name"] != null) {
setState(() {
driverName = event.snapshot.value["driver_name"].toString();
});
}
if (event.snapshot.value["driver_phone"] != null) {
setState(() {
driverphone = event.snapshot.value["driver_phone"].toString();
});
}
if (event.snapshot.value["driver_location"] != null) {
double driverLat = double.parse(
event.snapshot.value["driver_location"]["latitude"].toString());
double driverLng = double.parse(
event.snapshot.value["driver_location"]["longitude"].toString());
LatLng driverCurrentLocation = LatLng(driverLat, driverLng);
By default the snapshot's data type is Object
. You can explicit it to be of dynamic type by doing this,
builder: (context, AsyncSnapshot snapshot) { // setting up data type of snapshot as just AsyncSnapshot.
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.