Reputation: 73
How do i get the zipcode of a user based on their location from a flutter app.
Upvotes: 0
Views: 280
Reputation: 73
I figured this out after researching a bit
https://pub.dev/packages/location_plus
Future<dynamic> getCurrentLocation() async {
var result = await LocationPlus.getCurrentLocation();
setState(() {
print(result);
_locality = result['locality'];
_postalCode = result['postalCode'];
_administrativeArea = result['administrativeArea'];
_country = result['country'];
_latitude = double.parse(result['latitude']);
_longitude = double.parse(result['longitude']);
_ipAddress = result['ipAddress'];
});
}
the _postalCode is the zip code
Upvotes: 0