gpt4 book ai didi

flutter - 如何修复此语法错误?不可为 null 的实例字段 'students' 必须初始化

转载 作者:行者123 更新时间:2023-12-05 04:36:25 24 4
gpt4 key购买 nike

<分区>

错误在 StudentAdd(List.. and _StudentAddState(Lİst.. in first and second class) 给出

错误两次对我说“必须初始化不可为空的实例字段‘学生’。”和必须初始化不可为 null 的实例字段“students”。

我所有的代码:

class StudentAdd extends StatefulWidget {

List<Student> students;
StudentAdd(List<Student> students){

this.students = students;
}

@override
State<StatefulWidget> createState() {
return _StudentAddState(students);

}
}

class _StudentAddState extends State with StudentValidationMixin {

List<Student> students;

var student = Student.withInfo(0, '', '', 0);

var formKey = GlobalKey<FormState>();


_StudentAddState(List<Student> students){

this.students = students;
}
@override

Widget build(BuildContext context) {

// TODO: implement build

return Scaffold(

appBar: AppBar(

title: Text('Yeni Öğrenci Ekle'),
),
body: Container(

margin: EdgeInsets.all(20.0),
//margin: EdgeInsets.only(top: 20.0, right: 20.0, left: 20.0),
child: Form(
key: formKey,
child: Column(
children: <Widget>[
buildFirstNameField(),
buildLastNameField(),
buildGradeField(),
buildSubmitButton(),
],
),
),
),
);
}

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