您好,我想知道是否可以在dart / flutter中制作对象数组。
class Student {
int math;
}
Student[] studentArray = new
Student[7];
studentArray [0] =新的Student();
答案 0 :(得分:0)
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);
}