Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

[State Restoration] Use RestorableIntN, Fix DataTable #402

Merged
merged 5 commits into from
Jan 5, 2021

Conversation

shihaohong
Copy link

  • Use RestorableIntN to remove workaround for null values.
  • DataTable was incorrectly calling setState in the build method. This fixes that and sorts/populates the dessert data source upon state restoration instead.

@shihaohong shihaohong changed the title Use RestorableIntN, Fix DataTable state restoration [State Restoration] Use RestorableIntN, Fix DataTable Jan 4, 2021
@@ -32,6 +32,25 @@ class _DataTableDemoState extends State<DataTableDemo> with RestorationMixin {
registerForRestoration(_rowsPerPage, 'rows_per_page');
registerForRestoration(_sortColumnIndex, 'sort_column_index');
registerForRestoration(_sortAscending, 'sort_ascending');

_dessertsDataSource ??= _DessertDataSource(context);
if (_sortColumnIndex.value == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: might benefit from a switch statement instead

Copy link
Member

@guidezpl guidezpl left a comment

Choose a reason for hiding this comment

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

  _    ___ _____ __  __ 
 | |  / __|_   _|  \/  |
 | |_| (_ | | | | |\/| |
 |____\___| |_| |_|  |_|
                        

@shihaohong shihaohong merged commit 010b20d into flutter:master Jan 5, 2021
@shihaohong shihaohong deleted the restorable-int-n branch January 5, 2021 03:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants