flutterlocation
flutterlocation copied to clipboard
fix: No ToJson extension and also a few other extensions for LocationData Object
Description
A clear and concise description of what the bug is. Have you tried running flutter clean first ?
Expected behavior A clear and concise description of what you expected to happen.
Steps To Reproduce
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Tested on:
- Android, API Level XX [e.g. 31], simulator or real device
- iOS, Version XX [e.g. 15], simulator or real device
Other plugins:
- List of others Flutter plugins that could interfere
Additional logs
some logs
Had the same issue, so had to override the dependency to get the last update that still contained toJson
dependency_overrides:
location_platform_interface: 3.0.0
Seems like the override above no longer works, so instead I created my own extension which I can call from location.toJson()
extension LocationDataJson on LocationData {
Map<String, dynamic> toJson() {
return {
'latitude': latitude,
'longitude': longitude,
'accuracy': accuracy,
'altitude': altitude,
'speed': speed,
'speedAccuracy': speedAccuracy,
'heading': heading,
'time': time,
};
}
}