I'm little bit stuck on some situation.
1) type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'List<Map<String, dynamic>>'
My code.
List<Map<String, dynamic>> arrayOfProductList = List<Map<String, dynamic>>();
Calling APIs
Future<Map<String, dynamic>> _callWebServiceForGetProductList() async{
String strURL = 'http:xxxxxx/productlist.php';
Map<String, String> headerDic = {"Authorization": "ff624bc580ab48a3910d4352dxxx712"};
Map<String, String> paramDic = {"page": "1", "search": "", "term_id": ""};
http.Response httpRes = await http.post(strURL, headers: headerDic, body: paramDic);
Map<String, dynamic> responseDic = json.decode(httpRes.body);
return responseDic;
}
FutureBuilder Widget and stuff
Expanded(
child: Container(
child: FutureBuilder(
future: _callWebServiceForGetProductList(),
builder: (BuildContext context, AsyncSnapshot snap) {
if(snap.hasData) {
Map<String, dynamic> dicOfData = snap.data;
arrayOfProductList = dicOfData["data"] as List<Map<String, dynamic>>;
print(arrayOfProductList);
_setupProductListView();
}
else if(snap.hasError) {
showDialog(context: context, builder:(_) => AlertDialog(
content: Text("Error ${snap.hasError.toString()}"),
title: Text("Error"),
));
}
return Center(child: CircularProgressIndicator());
}
),
),
)
I'm googling for last 2 hours but didn't get any result. Where i'm going wrong? Guide me.
_InternalLinkedHashMapis the same asMap(just an internal representation). The value is aMap<String,dynamic>and the type you try to assgn to is aList<Map<String,dynamic>>. So you expect a list bat the actual value is not a list, it's a single value. - Günter Zöchbauer