Home>
problem

The following error occurred in Flutter.

Error:'Location' is imported from both'package: google_maps_webservice/src/core.dart' and'package: location/location.dart'.

We are using the following two packages.
https://pub.dev/packages/location
https://pub.dev/packages/google_maps_flutter

An error occurred when implementing the sample code below.

Location location = new Location ();
bool _serviceEnabled;
PermissionStatus _permissionGranted;
LocationData _locationData;
_serviceEnabled = await location.serviceEnabled ();
if (! _serviceEnabled) {
  _serviceEnabled = await location.requestService ();
  if (! _serviceEnabled) {
    return;
  }
}
_permissionGranted = await location.hasPermission ();
if (_permissionGranted == PermissionStatus.denied) {
  _permissionGranted = await location.requestPermission ();
  if (_permissionGranted! = PermissionStatus.granted) {
    return;
  }
}
_locationData = await location.getLocation ();
Supplement

The error is that Location is in both packages.
However, I would like to use both packages.

This is to get the current location with the Location package and display it on Google Map.
How can I get rid of the error?

environment

The result of flutter doctor -v is as follows.

(base) takumiendoh @ endoutakumiminoMac-mini minority% flutter doctor -v
[✓] Flutter (Channel master, 1.22.0-10.0.pre.137, on Mac OS X 10.15.6 19G2021, locale ja)
• Flutter version 1.22.0-10.0.pre.137 at /Users/takumiendoh/Documents/Development/flutter
• Framework revision 37e2013774 (2 days ago), 2020-09-11 04:05:02 -0400
• Engine revision bdaac368f8
• Dart version 2.10.0 (build 2.10.0-115.0.dev)

[✓] Android toolchain --develop for Android devices (Android SDK version 30.0.2)
• Android SDK at/Users/takumiendoh/Library/Android/sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.

[✓] Xcode --develop for iOS and macOS (Xcode 11.7)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.7, Build version 11E801a
• CocoaPods version 1.10.0.beta.2

[✓] Android Studio (version 4.0)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 48.1.2
• Dart plugin version 193.7547
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] Connected device (1 available)
• AOSP on IA Emulator (mobile) • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

• No issues found!