【问题标题】:The getter 'children' isn't defined for the class 'PageView'没有为“PageView”类定义吸气剂“孩子”
【发布时间】:2020-06-26 13:14:53
【问题描述】:

我只是不知道这怎么可能,但这里是代码:

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' 定义 getter 'children'”

【问题讨论】:

    标签: list flutter widget


    【解决方案1】:
    final List<Widget> children = [];
    
    PageView widgetPageView = PageView(
      children: children,
    );
    
    dataList.forEach((e) {
      Leader c = Leader.fromJson(e);
      children.add(Text('child 1'));
    });
    

    【讨论】:

      猜你喜欢
      • 2020-05-11
      • 2021-02-27
      • 2021-04-14
      • 2021-09-17
      • 2021-03-26
      • 2020-12-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多