When I try to get my current location in flutter with the default location package, I receive a core location error. My permissions on my device are enabled to allow location for the application and there are no other errors aside from when I try to open the map. As a result of this error, my current location coordinates are never returned from the function.
Full error:
[CoreLocation] This method can cause UI unresponsiveness if invoked on the main thread. Instead, consider waiting for the `-locationManagerDidChangeAuthorization:` callback and checking `authorizationStatus` first.
Thus far, I have tried a clean pod install and altering the permissions I have in info.plist. The only related issue to this involves Geolocation rather than default location (Flutter: geolocator Error? Warning? [CoreLocation] This method can cause UI unresponsiveness if invoked ... . I can't get GPS information).
void getCurrentLocation () {
Location location = Location(); // never executes past this point
location.getLocation().then(
(location) {
currentLocation = location;
});
}
Above is the code snippet in question. Additionally, this is my app delegate:
import UIKit
import Flutter
import GoogleMaps
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GMSServices.provideAPIKey("KEY")
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}