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()
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章