type MappedListIterable dynamic Widget is not a subtype of type List Widget

官方代码提示:

inal divided = ListTile.divideTiles(context: context, tiles: tiles);

      return new Scaffold(
        appBar: new AppBar(
          title: new Text("收藏"),
          centerTitle: true,
        ),
        body: new ListView(
          children: divided,
        ),
      );

错误原因:

ListView 的 children 属性需要的类型为 List,而 divided 是 Iterable 类型,所以会发生错误。

解决方法:

children: divided.toList()
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章