我该如何解决“扑扑”错误

时间:2020-06-30 04:17:16

标签: flutter dart

The name 'LocationAccuracy' is defined in the libraries 'package:geolocation/geolocation.dart', 'package:geolocator/geolocator.dart' and 'package:location_platform_interface/location_platform_interface.dart (via package:location/location.dart)'.
Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports.dartambiguous_import

enter image description here

1 个答案:

答案 0 :(得分:2)

此消息是因为在多个库中定义了一个LocationAccuracy。因此,您需要定义从哪个库获得此LocationAccuracy。因此,您需要在导入后指定一个前缀,如下所示:

import 'package:geolocation/geolocation.dart' as geo; // or whatever name you want
import 'package:geolocator/geolocator.dart' as geolocator; // or whatever name you want

然后您可以通过这种方式引用要使用的特定LocationAccuracy

geo.LocationAccuracygeolocator.LocationAccuracy