使用搜索功能显示从第三个第三方 API 获取的 A-List 错误仅在我运行应用程序时显示,它说 _InternalLinkedHashMap<String, dynamic>' 不是“Iterable”类型的子类型
Please Welp *** Edit A new Error Showed after playing with the code this error shows type 'String' is not a subtype of type Map-dynamic, dynamic-
Future<Null> getStoreDetails() async {
var basicAuth = 'Basic ' +
base64Encode(utf8.encode('api_token_key'));
var result;
var response = await http.get(url, headers: {'authorization': basicAuth});
if (response.statusCode == 200) {
var responseJson = json.decode(response.body);
setState(() {
/Where the error is
for (Map storedetails in responseJson) {
_searchResult.add(StoreDetails.fromJson(storedetails));
}
});
} else if (response.statusCode != 200) {
result = "Error getting response:\nHttp status ${response.statusCode}";
print(result);
}
}
@override
void initState() {
super.initState();
getStoreDetails();
}
数据模型类
class StoreDetails {
final int businessunitid;
String citydescription;
StoreDetails({
this.businessunitid,
this.citydescription,
});
factory StoreDetails.fromJson(Map<String, dynamic> data) {
return new StoreDetails(
businessunitid: data['businessunitid'],
citydescription: data['citydescription'],
);
}
}
错误
E/flutter ( 3566): type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'Iterable<dynamic>'
E/flutter ( 3566): #0 SearchStoreState.getStoreDetails.<anonymous closure> (package:rsc_prototype/screens/searchstore_screen.dart:43:34)
E/flutter ( 3566): #1 State.setState (package:flutter/src/widgets/framework.dart:1125:30)
E/flutter ( 3566): #2 SearchStoreState.getStoreDetails (package:rsc_prototype/screens/searchstore_screen.dart:42:7)
E/flutter ( 3566): <asynchronous suspension>
E/flutter ( 3566): #3 SearchStoreState.initState (package:rsc_prototype/screens/searchstore_screen.dart:56:5)
E/flutter ( 3566): #4 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3751:58)