-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/packages
#5355Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityp: pigeonrelated to pigeon messaging codegen toolrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team
Description
(Somewhat similar to #80048, but a distinct feature.)
A common NNBD pattern for data objects in Dart is to have optional collection members be non-nullable with default empty values, to avoid having two different ways of expressing "nothing" (null vs. empty). So an object where no arguments are required would look like:
class Foo {
Foo({
this.aString,
this.aDouble,
this.aList = const List<String>[],
this.aMap = const Map<String, int>{},
});
String? aString;
double? aDouble;
List<String> aList;
Map<String, int> aMap;
}
Since Pigeon doesn't allow default parameter values, we currently have to make the collections nullable which makes them error-prone on the native side (we've had real bugs due to native code checking for only one type of "empty"), or we have to make the parameters required which makes them more annoying to create on the Dart side.
pengdev, pratiktimer, apalala-dev, CedricConnectTech and Robert-SD
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityp: pigeonrelated to pigeon messaging codegen toolrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team