-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[State Restoration] [Reply] Partially State Restorable Pages #368
Conversation
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 looking great!
Can you also add some tests to ensure that we don't break state restoration for this app in the future? You can probably take some inspirations from the tests I added here: flutter/samples#433
|
||
// A set of the different mailbox pages that the Reply app | ||
// contains. An enum would be preferable, but only primitives | ||
// values are state restorable. |
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 agree, an enum would be better: Can you use an enum and store the index of the enum value (available via the .index
getter on an enum value) in the restoration state? To restore the original enum, you can use that index as an index into the values
constant of the enum.
listen: false, | ||
).isEmailStarred(email); | ||
|
||
// TODO(shihaohong): State restoration of mail view page is |
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.
Oh, did you by any chance take a look at OpenContainer to see what it would take to make that restorable?
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.
Discussion continued in flutter/flutter#69924.
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.
Can you add an issue link here?
I saw you also updated flutter/flutter#62916 with the additional work we need to do! Thanks! Can you also link these migration PRs against the issue so we have them all in one place? Thanks! |
We also need to investigate the crash you are reporting in the PR description. Even if OpenContainer doesn't support state restoration, it shouldn't crash... |
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!
// TODO(shihaohong): State restoration of compose page on mobile is | ||
// blocked because OpenContainer does not support restorablePush. |
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.
Can you add an issue link here?
listen: false, | ||
).isEmailStarred(email); | ||
|
||
// TODO(shihaohong): State restoration of mail view page is |
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.
Can you add an issue link here?
This makes most of the pages in the Reply app state restorable.
This PR does not yet include restoration of scrollable offset location, which I will complete in a separate PR.
State Restoration for Flutter is currently only enabled for Android (adding support for iOS is tracked in flutter/flutter#62915). In order to test the state restoration aspect of this app follow these steps:
This change required modifications to the email store logic and mail view logic since the state was so tightly coupled that it was difficult to make it state restorable without decoupling it. As nice side effects, the change removes duplicated state in the code, improves starring/unstarring mail handling. For example, before this change, starred emails would not appear in the other mailboxes (inbox, sent, draft), because it had its own unique category. Now, starred emails will still appear on those aforementioned pages.
Outstanding issue
State restoration is blocked on the mail view and compose pages due to the use of OpenContainer, which does not support the restorable Navigator APIs: flutter/flutter#69924. This is causing a crash when using an Android device when: