Ibrahim Memon
Ibrahim Memon

Reputation: 73

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

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

Upvotes: 0

Views: 280

Answers (1)

Ibrahim Memon
Ibrahim Memon

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

Related Questions