Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save evaisse/db16699b0d5d3093f07a9dfc3247ef70 to your computer and use it in GitHub Desktop.
Save evaisse/db16699b0d5d3093f07a9dfc3247ef70 to your computer and use it in GitHub Desktop.
class Cool {
final int count;
Cool({ int? count = 20 }): this.count = count ?? 20;
}
class NotCool {
final int count;
NotCool({ this.count = 20 });
}
void main() {
int? myArg = null;
Cool(
count: myArg
);
NotCool(
// invoke without having to know the default value is impossible...
count: myArg ?? 20
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment