I was using the google maps api and location pub,dev package in my android flutter app, and tried to bring up an image using the url from the api. This was the url with some code:
class LocationHelper{ static String mapviewpointer({double latitude, double longitude}){ return "https://maps.googleapis.com/maps/api/staticmap?center=$latitude,$longitude&zoom=13&size=600x300&maptype=roadmap&markers=color:pink%7Clabel:C%7C$latitude,$longitude&key=$GOOGLE_API_KEY"; } }
it threw the following error message:
Plugin project :location_web not found. Please update settings.gradle;
I'm not sure how to fix this error.
This was the other error I received in my terminal:
I/flutter (21880): Invalid argument(s): No host specified in URI file:///Instance%20of%20'Future%3CString%3E'
The Area in which I get the error message above is here in my code:
Future <String> _getUserLocation() async{ final locData = await Location().getLocation(); final staticMapUrl = LocationHelper.mapviewpointer( latitude: locData.latitude, longitude: locData.longitude, ); return staticMapUrl; } final mapview = _getUserLocation(); class NearbyScreen extends StatelessWidget { @override //LocationHelper.mapviewpointer(latitude: ) Widget build(BuildContext context) { return Column( children: <Widget>[ Container(height:170, width: double.infinity, child:Image.network(mapview.toString()) ), Text("hello"), ], ); } }
Does it have something to do with the fact that I am returning a Future<String>
instead of just a string
in my _getUserlocation
function? How could I fix this?
Use the following settings.gradle
:
include ':app' def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() def plugins = new Properties() def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') if (pluginsFile.exists()) { pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } } plugins.each { name, path -> def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() include ":$name" project(":$name").projectDir = pluginDirectory }
This will create a .flutter-plugin
file which will have the plugin and its path.
I had the same issue and following @Peter Haddad answer, I copy and replaced the code in settings.gradle (all of it) and I had errors resolving symbol for properties and file.
TO FIX IT: go to Tools -> Flutter -> Open for editing in Android Studio
In the Android Studio window go to File -> Invalidate Cache and Restart
This seemed to fix it for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With