location.getlocation() gives casting error on android flutter. An issue should be raised regarding this at the plugin location to either return proper results or throw appropriate errors.
You can try check for permission and then call location.getLocation()
1 2 3 4 5 6 7 8 9 10 11 12 | void _getLocation() async { Location location = Location(); if (await location.hasPermission()) { final LocationData pos = await location.getLocation(); setState(() { print(pos.runtimeType); _lastMapPosition = pos; }); } else { await location.requestPermission(); } } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.