gpt4 book ai didi

list - 使用 ListView 时出现错误 : The named parameter 'children' isn't defined,

转载 作者:IT王子 更新时间:2023-10-29 06:57:00 26 4
gpt4 key购买 nike

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

为了使 DataTable 可滚动,我将它包装在一个 ListView 中,按照这篇文章的评论: DataTable - make scrollable, set background colour and fix/freeze header row and first column

这是我的代码:

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});
}


预期输出:可滚动数据表。

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

最佳答案

您在代码中将 children 拼错为 childern

将您的 ListView 代码设为 -

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

关于list - 使用 ListView 时出现错误 : The named parameter 'children' isn't defined,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56142639/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com