使用 Flutter 时出错 "list":: Field 'students' should be initialized because its type 'List<Student>' doesn't allow null

Error when using Flutter "list":: Field 'students' should be initialized because its type 'List<Student>' doesn't allow null

我是 Flutter 的新手,我 运行 在自己的计算机上编写时遇到了问题,因为我的讲师使用的是旧版本。

class StudentAdd extends StatefulWidget {
 List<Student> students;
 StudentAdd(List<Student> students){
  this.students=students;

Error: Field 'students' should be initialized because its type 'List' doesn't allow null.

我收到上述错误并且无法修复。就我翻阅文档而言,我找不到任何结果。

StudentAdd(List students){

我在加粗的地方遇到错误,我得到的错误是:不可为空的实例字段 'students' 必须初始化。

将 ot 初始化为空列表,而不是将其保留为空值

List<Student> students = <Student>[];