Repository navigation
maintainState could have a clearer description #44836
Description
Activity
- addedf: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.d: api docsIssues with https://api.flutter.dev/Issues with https://api.flutter.dev/
on Nov 13, 2019 The documentation on this should be clearer. Do you want to submit a PR to improve it?
From #51748 (closed PR) for future reference if anyone wants to work on this.
When maintainState is set to false on a particular route, other routes below it may still be kept in memory (e.g. because they may have maintainState set to true). And even if this route has maintainState set to false and is not the topmost route it may be kept in memory when the route above it is not opaque. See also https://master-api.flutter.dev/flutter/widgets/OverlayEntry/maintainState.html.
This should probably be explained in the docs as well.
- addedc: performanceRelates to speed or footprint issues (see "perf:" labels)Relates to speed or footprint issues (see "perf:" labels)
on Sep 22, 2020 - addedP2Important issues not at the top of the work listImportant issues not at the top of the work list
on Dec 20, 2022 - addedteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
on Jul 8, 2023 - added a commit that references this issue
on Jul 19, 2023 - added a commit that references this issue
on Jul 31, 2023 This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.- locked as resolved and limited conversation to collaborators
on Aug 2, 2023
See felangel/bloc#669 for sample and examples.
Today I spent a lot of time trying to figure out why
maintainState = falsewas maintaining the state. Basically, if I open 5 widgets,mainTainState = truemaintains all five,mainTainState = falsemaintains only the first and last, andNavigator.pushReplacementonly the last.The issue is that maintainState (from MaterialPageRoute) explicitly says:
flutter/packages/flutter/lib/src/material/page.dart
Lines 22 to 24 in bcc93bc
This isn't true. When
maintainState = falseand you are usingpush, it is not freeing everything. I recommend you update the description to say what it is doing.