-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.r: solvedIssue is closed as solvedIssue is closed as solvedrefactorImproving readability/efficiency without behavioral changesImproving readability/efficiency without behavioral changesteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
It's fun to turn switch statements into switch expressions, but there are other interesting ways that pattern-matching can make things more concise & readable.
example (widget_inspector.dart):
// before
final Object? object = toObject(id);
if (object is Element) {
final RenderObject? renderObject = object.renderObject;
if (renderObject is RenderFlex) {
renderObject.mainAxisAlignment = mainAxisAlignment;
}
}
// after
if (toObject(id) case Element(:final RenderFlex renderObject)) {
renderObject.mainAxisAlignment = mainAxisAlignment;
}Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.r: solvedIssue is closed as solvedIssue is closed as solvedrefactorImproving readability/efficiency without behavioral changesImproving readability/efficiency without behavioral changesteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team