I'm new to flutter and I ran into a problem while writing on my own computer because my instructor was using an old version.
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.
I am getting the above error and could not fix it. As far as I looked through the documents, I couldn't find any results.
StudentAdd(List students){
I get an error where I bold it and the error I get is: Non-nullable instance field 'students' must be initialized.
CodePudding user response:
initialize ot as empty list instead of leaving it with null value
List<Student> students = <Student>[];