Dart – konstruktor

Konstruktor koristimo za pravljenje objekata klase.

class Student {

  String? first_name;
  String? last_name;
  int? age;
  int? year;

  //konstruktor
  Student(this.first_name, this.last_name, this.age, this.year);
}

void main() { 
   Student s = new Student("Maxim", "Tsigalko", 17, 3);
   print(s.first_name);
}