当前位置: 首页 > 知识库问答 >
问题:

类型_InternalLinkedHashMap不是类型列表的子类型

壤驷心思
2023-03-14

我有点被某些情况困住了。

1) type'\u InternalLinkedHashMap

我的密码。

List<Map<String, dynamic>> arrayOfProductList = List<Map<String, dynamic>>();

调用API

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;
  }

FutureBuilderWidget和其他东西

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());

                    }
                ),
              ),
            )

我在谷歌上搜索了两个小时,但没有得到任何结果。我错在哪里?指引我。


共有1个答案

章学义
2023-03-14

dicOfData["data"]转换为List的尝试

 类似资料: