【问题标题】:The argument type 'List<dynamic>?' can't be assigned to the parameter type 'List<dynamic>'. while using list参数类型 'List<dynamic>?'不能分配给参数类型“列表<动态>”。使用列表时
【发布时间】:2021-11-29 11:28:13
【问题描述】:

这是我的代码:

        future: getData(),
        builder: (context, snapshot) {
          if (snapshot.hasError) {
            print(snapshot.error);
          }
          return snapshot.hasData
              ? new ItemList(
                  list: snapshot.data,
                )
              : new Center(
                  child: new CircularProgressIndicator(),
                );
        },
      ),

“列表:snapshot.data”中出现错误 错误是 “参数类型'列表?'不能分配给参数类型“列表”。”

请帮我写代码,我使用的是最新版本的颤振。 谢谢…………

【问题讨论】:

  • 您可以在 dart 中查看Null Safety,以找到解决问题的方法。

标签: json flutter fetch


【解决方案1】:

你有空安全问题

list: snapshot.data!,

这将解决您的问题

【讨论】:

  • 是的,它已修复,非常感谢
猜你喜欢
  • 2021-09-10
  • 2021-10-24
  • 2021-09-15
  • 2021-10-18
  • 2020-10-11
  • 2021-11-13
  • 2021-12-24
  • 2021-10-28
  • 1970-01-01
相关资源
最近更新 更多