Flutter Https未处理异常:无效参数。

3
我想在列表视图中显示数据(例如硬编码示例) enter image description here 当我想获取该值时,它无法工作。
I/flutter ( 9640): [{"No":0,"interest":"0.00","balance":"11,000,000,000.00","principal":"0.00","Installment":"0.00","Status":true},{"No":1,"interest":"110,000,000.00","balance":"0.00","principal":"11,000,000,000.00","Installment":"11,110,000,000.00","Status":true}]
I/flutter ( 9640): true
E/flutter ( 9640): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Invalid argument(s)
E/flutter ( 9640): #0      _StringBase.+ (dart:core-patch/string_patch.dart:272:57)

这里是异步获取数据的FetchData

 List<LoanModel> _loanmodel = <LoanModel>[];

  Future<LoanModel> _fetchData() async {
    setState(() {
      loading = true;
    });
    final response =
    await http.get("http://192.168.0.23/Api/loansimulation.php?periodtime=" + periodtime + "&interestpermonth=" + interestpermonth + "&loanamountrequest=" +loanamountrequest); //with hardcode working fine
    if (response.statusCode == 200) {
      final data = jsonDecode(response.body);
      setState(() {
        for (Map i in data) {
          _loanmodel.add(LoanModel.fromJson(i));
        }
        loading = false;
      });
    }
  }

如何在Flutter中从API获取periodtime、interestpermonth和loanamountrequest的值,并根据输入值获得相应的值?
1个回答

2

我举了一个例子,展示了如何显示你可以从这个函数中获取到的数据

    listView.Builder(

     itemcount=_loanmodel.length;
     builder(context,index)
    {
     return Container(
    child:Column(
    childern[
    Text(_loanmodel[index].balance)
    ])
    );
    }

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接