大佬教程收集整理的这篇文章主要介绍了类型 'Future<Stations>' 不是类型 'Iterable<dynamic>' 的子类型,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
API 调用由按下按钮触发,该按钮调用 AnchoredMapMarkers,它应该在预加载的地图上显示经纬度图
print('step5.1_APICALL');
后返回 async
正常
错误显示为 type 'Future<Stations>' is not a subtype of type 'Iterable<dynamic>'
非常感谢任何帮助
API 调用并以列表形式很好地显示 - 我现在正在尝试从 Json 中提取经纬度并将其绘制在我的地图 SDK 上
class MapMarkerExample{
voID showAnchoredMapMarkers() {
var stations;
stations = fetchStations();
for (Station stations in stations) {
GeoCoordinates geoCoordinates = GeoCoordinates (stations.place.LOCATIOn.lat,stations.place.LOCATIOn.lng);
_addCircleMapMarker(geoCoordinates,0);
_addPOIMapMarker(geoCoordinates,1);
}
}
Future<Stations> fetchStations() async {
print('step5.1_APICALL');
var clIEnt = http.ClIEnt();
final response = await clIEnt.get(
'https://transit.hereAPI.com/v8/stations?in=lat,-long&return=transport&APIKey=API_KEY');
if (response.statusCode == 200) {
return Stations.fromJson(JsonDecode(response.body));
} else {
throw Exception('Failed to load stations');
}
}
你不是在等待你的未来。为了使编译器变得更加复杂,您以某种方式拆分了声明和赋值。并重用了一个变量名。
修复:
public enum UserType
{
AdminType,CustomerType
}
public void Print(UserType userTypE)
{
IPrinter printer;
switch(userTypE)
{
//write your logic
}
}
,
你需要等待
Future<void> showAnchoredMapMarkers() async {
var stations = await fetchStations();
for (Station stations in stations) {
GeoCoordinates geoCoordinates = GeoCoordinates (stations.place.LOCATIOn.lat,stations.place.LOCATIOn.lng);
_addCircleMapMarker(geoCoordinates,0);
_addPOIMapMarker(geoCoordinates,1);
}
}
以上是大佬教程为你收集整理的类型 'Future<Stations>' 不是类型 'Iterable<dynamic>' 的子类型全部内容,希望文章能够帮你解决类型 'Future<Stations>' 不是类型 'Iterable<dynamic>' 的子类型所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。