是否可以在 Dart/Flutter 中创建对象数组

mas*_*son 6 dart flutter

你好,我想知道是否可以在 dart/flutter 中创建一个对象数组。

class Student {
int math;
}

Student[] studentArray = new 
Student[7];
Run Code Online (Sandbox Code Playgroud)

StudentArray[0] = new Student();

Doc*_*Doc 4

void main() {
  List persons = [User("foo"), User("bar")]; //non-empty on create


  List users = []; //blank initially
  for (int i = 0; i < 5; i++) {
    users.add("User $i");
  }

//print using iterator
  for (var u in users) {
    print(u);
  }

  /*
   * first element can be accessed using users[0] or users.first
   * last element can be accessed using users.last
   * */
}

class User {
  String name;
  User(this.name);
}
Run Code Online (Sandbox Code Playgroud)