how do i resolve' as prefix' in flutter error

Viewed 4437
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 Answers

This message is because there's a LocationAccuracy defined in more than one library. So you need define from which library you are getting this LocationAccuracy. So you need specify a prefix after the import like this:

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

And then you can refer to the specific LocationAccuracy you want to use in this way:

geo.LocationAccuracy or geolocator.LocationAccuracy

Related