I am getting this error: Type 'Geolocator' not found and 'Placemark' isn't a type. Whenever I try to do flutter run, I get this error:
lib/screens/register.dart:33:9: Error: Type 'Geolocator' not found.
final Geolocator geolocator = Geolocator()..forceAndroidLocationManager;
^^^^^^^^^^
lib/screens/profile_edit.dart:33:9: Error: Type 'Geolocator' not found.
final Geolocator _geolocator = Geolocator()..forceAndroidLocationManager;
^^^^^^^^^^
lib/screens/register.dart:33:9: Error: 'Geolocator' isn't a type.
final Geolocator geolocator = Geolocator()..forceAndroidLocationManager;
^^^^^^^^^^
lib/screens/register.dart:33:33: Error: Method not found: 'Geolocator'.
final Geolocator geolocator = Geolocator()..forceAndroidLocationManager;
^^^^^^^^^^
lib/screens/register.dart:108:12: Error: 'Placemark' isn't a type.
List<Placemark> p = await geolocator.placemarkFromCoordinates(
^^^^^^^^^
lib/screens/register.dart:111:7: Error: 'Placemark' isn't a type.
Placemark place = p[0];
^^^^^^^^^
lib/screens/profile_edit.dart:33:9: Error: 'Geolocator' isn't a type.
final Geolocator _geolocator = Geolocator()..forceAndroidLocationManager;
^^^^^^^^^^
lib/screens/profile_edit.dart:33:34: Error: Method not found: 'Geolocator'.
final Geolocator _geolocator = Geolocator()..forceAndroidLocationManager;
^^^^^^^^^^
lib/screens/profile_edit.dart:70:12: Error: 'Placemark' isn't a type.
List<Placemark> p = await _geolocator.placemarkFromCoordinates(
^^^^^^^^^
lib/screens/profile_edit.dart:73:7: Error: 'Placemark' isn't a type.
Placemark place = p[0];
^^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 896
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 24s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 25.3s
Exception: Gradle task assembleDebug failed with exit code 1
Why I ran into this problem, that, I am still figuring out.
How it started?
Before I did the flutter upgrade. While processing my electricity went, and this process got interrupted, due to this, flutter got corrupted.
What I did then?
I re-installed the Flutter, and then made some changes. Did these:
- Flutter pubspec.lock file removal
- Running flutter clean
- Running flutter run
It somehow removed my packages issue, but still I was getting the errors while running. Then I did that
flutter upgrade --force // which gave me that I am on stable and upgraded
flutter pub cache repair // which downloaded the packages again, except few failures which I ignored, not related to geolocator
flutter clean
flutter run
Again the same error, which I have mentioned above.
Now, what I am stipulating is, there are some sort of package deprecation problems, but I am already using the latest package that is geolocator 6.0.0+1
Show me flutter doctor -v or flutter doctor
Here you go
[√] Flutter (Channel stable, 1.20.3, on Microsoft Windows [Version 10.0.18363.1016],
locale en-US)
• Flutter version 1.20.3 at C:\flutter
• Framework revision 216dee60c0 (2 days ago), 2020-09-01 12:24:47 -0700
• Engine revision d1bc06f032
• Dart version 2.9.2
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at C:\Users\ALOKKU~1\AppData\Local\Android\Sdk
• Platform android-29, build-tools 29.0.2
• ANDROID_HOME = C:\Users\ALOKKU~1\AppData\Local\Android\Sdk
• ANDROID_SDK_ROOT = C:\Users\ALOKKU~1\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
• All Android licenses accepted.
[√] Android Studio (version 3.6)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 44.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[√] VS Code (version 1.48.2)
• VS Code at C:\Users\ALOK KUMAR\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.13.2
[√] Connected device (1 available)
• ONEPLUS A6010 (mobile) • 4ee3072b • android-arm64 • Android 10 (API 29)
• No issues found!
How can I sort this out?