Update
Yes, the =
is allowed in Dart 2 and is now preferred over the :
to match optional positional parameters.
Person({this.name = "defaultName", this.age = "defaultAge"});
Old Answer
You just have to use a colon instead of equals
class Person {
String name;
String age;
Person({this.name: "defaultName", this.age: "defaultAge"});
}
I find this still confusing that optional parameters use =
to assign defaults but named use :
.
Should ask myself.