class Car {
String model;
String brand;
String _engine;
static int carProduced = 0;
Car(String model, String brand, String engine) {
this._engine = engine;
this.brand = brand;
this.model = model;
}
}
I am getting this error.
Non-nullable instance field '_engine' must be initialized.
Try adding an initializer expression, or add a field initializer in this constructor, or mark it 'late'.
I am not actually sure. As I am initializing that non-nullable field in the default constructor why do I need to use a late modifier here?
String model = "";
String brand = "";
String _engine = "";
Adding initializer expression solved the error. Does it mean that object fields are created even before the constructor call ??