我在运行我的应用时遇到以下错误
错误:在此Consumer << Position>小部件上方找不到正确的Provider
我在这里附加了我的代码。
class MyApp extends StatelessWidget {
final geoService = GeolocatorService();
@override
Widget build(BuildContext context) {
return FutureProvider<dynamic>(
create: (context) async => geoService.getInitialLocation(),
child: MaterialApp(
home: Consumer<Position>(
builder: (context, position, widget) {
return Maps(position);
},
),
),
);
}
}
我的服务班级是...
class GeolocatorService {
Stream getCurrentLocation() {
return getPositionStream(
distanceFilter: 10, desiredAccuracy: LocationAccuracy.high);
}
Future getInitialLocation() async {
return getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
}
}
我发现的错误
错误:在此Consumer << Position>小部件
上方找不到正确的提供者