You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So that MyStructure.id would be 0 and MyStructure.name would be "" by default.
Wonder if there was something equivalent to this approach/suger in Dart?
The text was updated successfully, but these errors were encountered:
Note that you can just write the regular class with their defaults today, as @mnordine said. You can also put the defaults in the constructor for slightly more control.
classMyClass {
int? id;
String? name;
MyClass.allNull({this.id, this.name}); // leaves fields null if not given a valueMyClass.nonNull({this.id =0, this.name =""); // will give every field a default
}
Given following rust code:
So that
MyStructure.id
would be0
andMyStructure.name
would be""
by default.Wonder if there was something equivalent to this approach/suger in Dart?
The text was updated successfully, but these errors were encountered: