-
Notifications
You must be signed in to change notification settings - Fork 224
Open
Labels
featureProposed language feature that solves one or more problemsProposed language feature that solves one or more problems
Description
Since we have this type in other languages, it would be nice to have it in Dart. It'll greatly strengthen the usefulness of copyWith
functions, so that null
values can be differentiated from values that have not been defined.
Use case:
class MapState1 {
MapState copyWith({
Category activeTopCategory,
Category activeCategory,
}) {
return MapState(
activeTopCategory: activeTopCategory ?? this.activeTopCategory,
activeCategory: activeCategory ?? this.activeCategory,
);
}
If I decide to set the activeCategory
to null, the newly created object will have the same values as the old object. I cannot figure out a reasonable workaround for this.
The second use-case is more common in widgets with optional named parameters with default values. If someone passes in that value using a variable and that variable turns out to be null, we don't get the default value, and there's no way to pass in a value sometimes and leave it undefined at others without creating 2 separate widgets.
mono0926, stegrams, denixport, HerrNiklasRaab, escamoteur and 15 moredenixport, awulkan, edTheGuy00, novemberisms, thosakwe and 15 more
Metadata
Metadata
Assignees
Labels
featureProposed language feature that solves one or more problemsProposed language feature that solves one or more problems