-
Notifications
You must be signed in to change notification settings - Fork 29.2k
[State Restoration] Scaffold.drawer and Scaffold.endDrawer #72788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[State Restoration] Scaffold.drawer and Scaffold.endDrawer #72788
Conversation
if (status == AnimationStatus.completed || status == AnimationStatus.dismissed) { | ||
_restorableAnimationValue.value = _controller.value; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should just store a bool then to indicate open or closed?
/// The state of this widget is persisted in a [RestorationBucket] claimed | ||
/// from the surrounding [RestorationScope] using the provided restoration ID. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not true, but it should be :)
Right now, it doesn't use the provided restoration ID and instead uses ${restorationId}_end_drawer
and ${restorationId}_drawer
.
I think you want ScaffoldState to use the RestorationMixin, which makes it claim a bucket using restorationId
. Then you insert that Bucket into the widget hierarchy around the two DrawerController using a UnmanagedRestorationScope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually decided to pull out the restorable drawer open/close states into ScaffoldState
, which I think is better because I worry about having two separate drawer open/close states in both the Scaffold and the Drawer widgets not aligning. PTAL and let me know what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. That's even better!
Looks like this is causing some test failures. |
Fixed the failing tests. Just needed to make sure to address when Edit: Looks like some other set of tests are now failing. I'll look into it Edit2: The isDrawerOpen parameter was causing drawers that were mid-animation to snap into place when the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
Adds state restoration capabilities to the drawer and endDrawer.
Related Issues
Fixes #70925
Related to #62916
Tests
I added the following tests:
Checklist
Before you create this PR, confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.///
).flutter analyze --flutter-repo
) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.