Hello everyone I am trying to build a flutter to display the latitude and the longitude but I still get an error here is the code :
void initState(){
super.initState();
//Default variable set 0
currentLocation['latitude'] = 0.0;
currentLocation['longtitude'] = 0.0;
initPlatformState();
locationSubscription = location.onLocationChanged.listen((Map<String, double> result){
setState(() {
currentLocation = result;
});
});
}
onLocationChanged
is a function, so you need to call it to get back the stream onLocationChanged().listen
should do what you need.