如何从 flutter 应用程序中根据用户的位置获取用户的邮政编码。
经过一番研究后我发现了这一点
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 是邮政编码