Skip to content

Expose a mounted-like flag on BuildContext #111488

@goderbauer

Description

@goderbauer

The popular use_build_context_synchronously lint suggests to check for mounted before using the context after an asynchronous gap. However, mounted only exists on StatefullWidgets. At the same time, StatelessWidgets suffer under the same problem: The context can become invalid after an asynchronous gap and there is currently no way to check whether it is still valid since there is no mounted property. A work-around is to turn the StatelessWidget into a StatefulWidget.

We should expose some kind of a property on BuildContext directly to check whether the context is still valid to simplify usage of context after an asynchronous gaps in these use cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: proposalA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions