错误:使用ListView时未定义命名参数'children'

阿比纳什三病

我正在使用Firebase实时数据库检索信息,然后将其显示在可滚动的DataTable中。

为了使DataTable可滚动,我按照这篇文章的评论将其包装在ListView中:DataTable-使可滚动,设置背景颜色以及修复/冻结标题行和第一列

这是我的代码:

import 'package:flutter/material.dart';
import 'package:firebase_database/firebase_database.dart';
import 'cprdata.dart';
import 'dart:convert';


class CprAnalysis extends StatefulWidget {
  @override
  CPRState createState() => CPRState();
}

class CPRState extends State<CprAnalysis> {

  ///var cpr = UpdateData.getData();
  List<FilterData> acData;

  List<FilterData> getData() {
    var cpr = <FilterData>[];

    DatabaseReference cprData = FirebaseDatabase.instance.reference();
    cprData.reference().once().then((DataSnapshot snap) {
      var d = snap.value;
      final jsonE = json.encode(d);
      final jsonResponse = json.decode(jsonE);
      MyDataList zz = new MyDataList.fromJson(jsonResponse);
      zz.myList.forEach((data) {
        cpr.add(FilterData(sYMBOL: data.SYMBOL, fORECAST: data.FORECAST));
      }
      );
    },
    );
    print(cpr);
    return cpr;
  }

  @override
  void initState() {
    super.initState();
    acData = getData();
  }

  Widget bodydata() => Expanded(
            child: ListView(
              ///shrinkWrap: true,
              padding: const EdgeInsets.all(8.0),
              childern: <Widget>[
                SingleChildScrollView(
                  scrollDirection: Axis.horizontal,
                  child: DataTable(
                  columns: <DataColumn>[
                    DataColumn(
                      label: Text("Symbol"),
                      numeric: false,
                    ),
                    DataColumn(
                      label: Text("Forecast"),
                      numeric: false,
                    ),
                  ],

                  rows: acData.map((data) =>
                      DataRow(
                        cells: [
                          DataCell(
                            Text(data.sYMBOL),
                            showEditIcon: false,
                            placeholder: false,
                          ),
                          DataCell(
                            Text(data.fORECAST),
                            showEditIcon: false,
                            placeholder: false,
                          )
                        ],
                      ),
                  )
                      .toList()
              ),
          ),
          ]
        ),
  );

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("CPR Analysis"),
      ),
      body: Container(

        child: bodydata(),
      ),
    );
  }
}


class FilterData {
  String sYMBOL, fORECAST;

  FilterData({
    this.sYMBOL,
    this.fORECAST});
}


预期输出:Scrollable DataTable。

实际输出:错误:未在ListView()下定义命名参数'childern'

Thebuggycoder

你拼错childrenchildern您的代码。

将您的ListView代码设为-

ListView(
  children: <Widget> [
    //Your remaining code
  ]
),

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

反应this.props.children是未定义的

未定义的值.children()。each()

使用props.children时,useLayoutEffect上的ref未定义

当使用this.props.children渲染子代时,React上下文未定义

使用react-router-redux时this.props.children未定义

Flutter:使用“ children:<Widget>”还是“ children:”?

ReactJS-{this.props.children}未定义

Ruby 2.4.1 Dir.children(dirname)返回“ Dir:Class的未定义方法'children'”

使用 TypeScript 反应 children[] 问题

当使用:first时children()和find()的行为

将函数传递给子组件this.props.children方法未定义

未处理的拒绝(TypeError):无法读取未定义的属性“ children”

React-sidenav:TypeError:无法读取未定义的属性“ children”

JavaScript .children.length()返回错误的值

每当我写“样式”时,我都会收到一个错误命名参数未定义

什么是{this.props.children}?何时使用?

ReactJS:为什么使用this.props.children?

在jQuery中使用.children和.find

我可以在匹配的 Children 中使用 jQuery

使用顶级 React Children API 映射孩子

AnimationController未定义命名参数“ vsync”

未定义命名参数'colors'。

未定义命名参数“textStyle”

如果还使用children参数,请使用redirectTo,这可能吗?

可折叠树d3 v3上的“ TypeError:root.children未定义”

React-Typesciprt:此JSX标签的'children'属性期望一个'Element | 未定义”,但提供了多个孩子

iOS应用在发布模式下崩溃“未定义不是对象(正在评估'e.propTypes.children')”

模板类成员使用类本身作为模板参数时发生未定义的类错误

Flutter:我正在尝试使用扩展类包装Text小部件,但出现“未定义命名参数'child'的错误”