Geolocator.getServiceStatusStream() 未定义?
Geolocator.getServiceStatusStream() is not defined?
我在项目中使用 Geolocator
版本 7.0.3
flutter 包,想监听服务状态变化。他们在文档中指出:
To listen for service status changes you can call the getServiceStatusStream. This will return a Stream which can be listened to, to receive location service status updates.
import 'package:geolocator/geolocator.dart';
StreamSubscription<ServiceStatus> serviceStatusStream = Geolocator.getServiceStatusStream().listen(
(ServiceStatus status) {
print(status);
});
但是调用Geolocator.getServiceStatusStream();
时显示此错误:
The method 'getServiceStatusStream' isn't defined for the type 'Geolocator'.
Try correcting the name to the name of an existing method, or defining a method named 'getServiceStatusStream'.
没有说他们把它移到别处或删除了它。
确保使用 7.1.0
或更高版本
我在项目中使用 Geolocator
版本 7.0.3
flutter 包,想监听服务状态变化。他们在文档中指出:
To listen for service status changes you can call the getServiceStatusStream. This will return a Stream which can be listened to, to receive location service status updates.
import 'package:geolocator/geolocator.dart';
StreamSubscription<ServiceStatus> serviceStatusStream = Geolocator.getServiceStatusStream().listen(
(ServiceStatus status) {
print(status);
});
但是调用Geolocator.getServiceStatusStream();
时显示此错误:
The method 'getServiceStatusStream' isn't defined for the type 'Geolocator'. Try correcting the name to the name of an existing method, or defining a method named 'getServiceStatusStream'.
没有说他们把它移到别处或删除了它。
确保使用 7.1.0
或更高版本