有没有办法从 flutter 应用程序获取当前的邮政编码?

问题描述 投票:0回答:1

如何从 flutter 应用程序中根据用户的位置获取用户的邮政编码。

flutter dart location zipcode
1个回答
0
投票

经过一番研究后我发现了这一点

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'];
});
}

_postalCode 是邮政编码

© www.soinside.com 2019 - 2024. All rights reserved.