Skip to content

"mounted" state should be automatically checked by flutter instead of forcing code to "fix" it #62030

@phackwer

Description

@phackwer

The following message was presented when an async call took longer than expected to get a version.txt file for the web build of a flutter app. The app has a custom splash screen which presents the version and build number from a txt file since PackageInfo do not work on the web.

"The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is
to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree."

Shouldn't setState automatically check this to avoid the error? Instead we have to code things like

    if (mounted) {
      setState(() {

Not cool

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.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions