我遇到了 geolocator 包的问题,当我在调试模式下运行我的应用程序时,一切正常,但是当我构建应用程序并使用发布模式时,它卡在了我的加载屏幕中,其中有来自 geolocator 包的 getcurrentlocation。
Future<void> getCurrentLocation() async {
try {
Geolocator geolocator = Geolocator()..forceAndroidLocationManager = true;
Position position = await geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.low,
);
latitude = position.latitude;
longitude = position.longitude;
} catch (e) {
print(e);
}
}
并添加到 android 清单访问。