I added Google Maps API to Flutter app and it keeps returning a blank screen with the error Unexpected response code 400 for https://clients4.google.com/glm/mmap/api
I added the API to every possible location and I've made dozens of new API KEYS
and projects, disabled and enabled API's, ran Flutter Clean
15 times, read the documentation TWICE, read a couple of Stack Overflow questions and did everything every answer and comment said but NOTHING, Can anyone please help.
IOS:
import UIKit
import Flutter
import GoogleMaps
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
GMSServices.provideAPIKey("KEY HERE")
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
Android:
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="KEY HERE"/>
//
//
minSdkVersion 20
Maps.dart:
class Mapp extends StatefulWidget {
const Mapp({Key? key}) : super(key: key);
static final kInitialPosition = LatLng(-33.8567844, 151.213108);
@override
_MappState createState() => _MappState();
}
class _MappState extends State<Mapp> {
PickResult? selectedPlace;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Google Map Place Picker"),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
ElevatedButton(
child: Text("Load Google Map"),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return PlacePicker(
apiKey: "KEY HERE",
// APIKeys.apiKey,
initialPosition: Mapp.kInitialPosition,
useCurrentLocation: true,
selectInitialPosition: true,
//usePlaceDetailSearch: true,
onPlacePicked: (result) {
selectedPlace = result;
Navigator.of(context).pop();
setState(() {});
},
);
},
),
);
},
),
selectedPlace == null
? Container()
: Text(selectedPlace?.formattedAddress ?? ""),
],
),
));
}
}