Skip to content

Improve page.dart documentation - #51748

Closed
bernaferrari wants to merge 1 commit into
flutter:masterfrom
bernaferrari:page
Closed

bernaferrari wants to merge 1 commit into
flutter:masterfrom
bernaferrari:page

Conversation

@bernaferrari

Copy link
Copy Markdown
Contributor

Description

Possible documentation fix for: #44836
I'm open to discussions.

Related Issues

Today I spent a lot of time trying to figure out why maintainState = false was maintaining the state. Basically, if I open 5 widgets, mainTainState = true maintains all five, mainTainState = false maintains only the first and last, and Navigator.pushReplacement only the last.

The issue is that maintainState (from MaterialPageRoute) explicitly says...

#44836

@fluttergithubbot

Copy link
Copy Markdown
Contributor

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@fluttergithubbot fluttergithubbot added p: material_ui material_ui package in flutter/packages framework flutter/packages/flutter repository. See also f: labels. labels Mar 1, 2020
@Piinks Piinks added f: routes Navigator, Router, and related APIs. d: api docs Issues with https://api.flutter.dev/ documentation labels Mar 4, 2020
/// [maintainState] to false.
/// remains in memory. To free resources when this is not necessary, set
/// [maintainState] to false. When [maintainState] is false, it stills maintains
/// the first, and only the first, route in memory. Use [Navigator.pushReplacement]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This statement sounds misleading. 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.

/// remains in memory. To free resources when this is not necessary, set
/// [maintainState] to false. When [maintainState] is false, it stills maintains
/// the first, and only the first, route in memory. Use [Navigator.pushReplacement]
/// to free every route from memory.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can one use pushReplacement to free every route from memory? And why is it desirable to even do this? You'd be left with a blank screen.

@Piinks Piinks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @bernaferrari are you planning to come back to work on this some more? :)

@bernaferrari

Copy link
Copy Markdown
Contributor Author

Yes, no, maybe. I actually don't know how to improve on what was commented :(

@lock

lock Bot commented Apr 2, 2020

Copy link
Copy Markdown

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 -v and a minimal reproduction of the issue.

@lock lock Bot locked and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

d: api docs Issues with https://api.flutter.dev/ f: routes Navigator, Router, and related APIs. framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants