Skip to content

Adopt null aware elements in the framework #172188

@Piinks

Description

@Piinks

Null-aware elements offer a shorthand for adding an element to a list, if the element is non-null. Consider this code before the feature:

Stack(
  fit: StackFit.expand,
  children: [
    const AbsorbPointer(),
    if (widget.child != null) widget.child!,
  ],
)

This causes repetition of widget.child, and is verbose. With null-aware elements this becomes:

Stack(
  fit: StackFit.expand,
  children: [
    const AbsorbPointer(),
    ?widget.child,
  ],
)

Now that the framework has adopted Dart 3.8 (#171703), we can adopt this feature in the framework too!

Important

Doing this successfully will involve several smaller PRs, rather than one big one that migrates the whole framework at once. Please do not send a mega-PR, break the changes up into sections.

cc @justinmc and @loic-sharma for visibility. :)

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listc: tech-debtTechnical debt, code quality, testing, etc.frameworkflutter/packages/flutter repository. See also f: labels.good first issueRelatively approachable for first-time contributorsrefactorImproving readability/efficiency without behavioral changesteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions