未为类“ PageView”定义吸气剂“子级”

时间:2020-03-15 01:02:26

标签: list flutter widget

我对如何做到这一点一无所知,但这是代码:

PageView widgetPageView = new PageView(children: <Widget>[],);

dataList.forEach((e){
  Leader c = Leader.fromJson(e);
  widgetPageView.children.add(*unimportant stings*); <--- Error here
});

问题是,当我定义PageView时,它具有“子级” getter,而在for循环中则没有。请帮忙。错误本身是“未为类'PageView'定义吸气剂'孩子'”

1 个答案:

答案 0 :(得分:0)

final List<Widget> children = [];

PageView widgetPageView = PageView(
  children: children,
);

dataList.forEach((e) {
  Leader c = Leader.fromJson(e);
  children.add(Text('child 1'));
});