【发布时间】:2020-10-02 12:33:53
【问题描述】:
我在我的 android Flutter 应用程序中使用 google maps api 和 location pub,dev 包,并尝试使用 api 中的 url 显示图像。 这是带有一些代码的网址:
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";
}
}
它抛出了以下错误消息:
Plugin project :location_web not found. Please update settings.gradle;
我不确定如何解决此错误。
这是我在终端中收到的另一个错误:
I/flutter (21880): Invalid argument(s): No host specified in URI file:///Instance%20of%20'Future%3CString%3E'
我收到上述错误消息的区域在我的代码中:
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"),
],
);
}
}
这是否与我在 _getUserlocation 函数中返回 Future<String> 而不仅仅是 string 的事实有关?我该如何解决这个问题?
【问题讨论】:
-
你能出示你的
pubspec.yaml吗?
标签: flutter dart google-maps-api-3 flutter-dependencies flutter-web