Is there a way to get your current zipcode from a flutter app?

96 views Asked by At

How do i get the zipcode of a user based on their location from a flutter app.

1

There are 1 answers

0
Ibrahim Memon On

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