diff --git a/lib/codeviewer/code_segments.dart b/lib/codeviewer/code_segments.dart index 2d96fa9efd..4519f84ebe 100644 --- a/lib/codeviewer/code_segments.dart +++ b/lib/codeviewer/code_segments.dart @@ -18042,6 +18042,242 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.classStyle, text: '_RestorableDessertSelections'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'extends'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorableProperty'), + TextSpan(style: codeStyle.punctuationStyle, text: '<'), + TextSpan(style: codeStyle.classStyle, text: 'Set'), + TextSpan(style: codeStyle.punctuationStyle, text: '<'), + TextSpan(style: codeStyle.keywordStyle, text: 'int'), + TextSpan(style: codeStyle.punctuationStyle, text: '>>'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'Set'), + TextSpan(style: codeStyle.punctuationStyle, text: '<'), + TextSpan(style: codeStyle.keywordStyle, text: 'int'), + TextSpan(style: codeStyle.punctuationStyle, text: '>'), + TextSpan(style: codeStyle.baseStyle, text: ' _dessertSelections '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{};'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '), + TextSpan( + style: codeStyle.commentStyle, + text: + '/// Returns whether or not a dessert row is selected by index.'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'bool'), + TextSpan(style: codeStyle.baseStyle, text: ' isSelected'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.keywordStyle, text: 'int'), + TextSpan(style: codeStyle.baseStyle, text: ' index'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '=>'), + TextSpan(style: codeStyle.baseStyle, text: ' _dessertSelections'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'contains'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'index'), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '), + TextSpan( + style: codeStyle.commentStyle, + text: + '/// Takes a list of [_Dessert]s and saves the row indices of selected rows'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.commentStyle, text: '/// into a [Set].'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'void'), + TextSpan(style: codeStyle.baseStyle, text: ' setDessertSelections'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.classStyle, text: 'List'), + TextSpan(style: codeStyle.punctuationStyle, text: '<'), + TextSpan(style: codeStyle.classStyle, text: '_Dessert'), + TextSpan(style: codeStyle.punctuationStyle, text: '>'), + TextSpan(style: codeStyle.baseStyle, text: ' desserts'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'final'), + TextSpan(style: codeStyle.baseStyle, text: ' updatedSet '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '<'), + TextSpan(style: codeStyle.keywordStyle, text: 'int'), + TextSpan(style: codeStyle.punctuationStyle, text: '>{};'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'for'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.keywordStyle, text: 'var'), + TextSpan(style: codeStyle.baseStyle, text: ' i '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.numberStyle, text: '0'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: ' i '), + TextSpan(style: codeStyle.punctuationStyle, text: '<'), + TextSpan(style: codeStyle.baseStyle, text: ' desserts'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'length'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: ' i '), + TextSpan(style: codeStyle.punctuationStyle, text: '+='), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.numberStyle, text: '1'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'var'), + TextSpan(style: codeStyle.baseStyle, text: ' dessert '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' desserts'), + TextSpan(style: codeStyle.punctuationStyle, text: '['), + TextSpan(style: codeStyle.baseStyle, text: 'i'), + TextSpan(style: codeStyle.punctuationStyle, text: '];'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'if'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'dessert'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'selected'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a updatedSet'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'add'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'i'), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a _dessertSelections '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' updatedSet'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a notifyListeners'), + TextSpan(style: codeStyle.punctuationStyle, text: '();'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: '@override'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'Set'), + TextSpan(style: codeStyle.punctuationStyle, text: '<'), + TextSpan(style: codeStyle.keywordStyle, text: 'int'), + TextSpan(style: codeStyle.punctuationStyle, text: '>'), + TextSpan(style: codeStyle.baseStyle, text: ' createDefaultValue'), + TextSpan(style: codeStyle.punctuationStyle, text: '()'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '=>'), + TextSpan(style: codeStyle.baseStyle, text: ' _dessertSelections'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: '@override'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'Set'), + TextSpan(style: codeStyle.punctuationStyle, text: '<'), + TextSpan(style: codeStyle.keywordStyle, text: 'int'), + TextSpan(style: codeStyle.punctuationStyle, text: '>'), + TextSpan(style: codeStyle.baseStyle, text: ' fromPrimitives'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.classStyle, text: 'Object'), + TextSpan(style: codeStyle.baseStyle, text: ' data'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'final'), + TextSpan(style: codeStyle.baseStyle, text: ' selectedItemIndices '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' data '), + TextSpan(style: codeStyle.keywordStyle, text: 'as'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'List'), + TextSpan(style: codeStyle.punctuationStyle, text: '<'), + TextSpan(style: codeStyle.keywordStyle, text: 'dynamic'), + TextSpan(style: codeStyle.punctuationStyle, text: '>;'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a _dessertSelections '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '...'), + TextSpan(style: codeStyle.baseStyle, text: 'selectedItemIndices'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'map'), + TextSpan(style: codeStyle.punctuationStyle, text: '<'), + TextSpan(style: codeStyle.keywordStyle, text: 'int'), + TextSpan(style: codeStyle.punctuationStyle, text: '>(('), + TextSpan(style: codeStyle.keywordStyle, text: 'dynamic'), + TextSpan(style: codeStyle.baseStyle, text: ' id'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '=>'), + TextSpan(style: codeStyle.baseStyle, text: ' id '), + TextSpan(style: codeStyle.keywordStyle, text: 'as'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'int'), + TextSpan(style: codeStyle.punctuationStyle, text: '),'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '};'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'return'), + TextSpan(style: codeStyle.baseStyle, text: ' _dessertSelections'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: '@override'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'void'), + TextSpan(style: codeStyle.baseStyle, text: ' initWithValue'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.classStyle, text: 'Set'), + TextSpan(style: codeStyle.punctuationStyle, text: '<'), + TextSpan(style: codeStyle.keywordStyle, text: 'int'), + TextSpan(style: codeStyle.punctuationStyle, text: '>'), + TextSpan(style: codeStyle.baseStyle, text: ' value'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a _dessertSelections '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' value'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: '@override'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'Object'), + TextSpan(style: codeStyle.baseStyle, text: ' toPrimitives'), + TextSpan(style: codeStyle.punctuationStyle, text: '()'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '=>'), + TextSpan(style: codeStyle.baseStyle, text: ' _dessertSelections'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'toList'), + TextSpan(style: codeStyle.punctuationStyle, text: '();'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'class'), + TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.classStyle, text: '_DataTableDemoState'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.keywordStyle, text: 'extends'), @@ -18059,6 +18295,28 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.keywordStyle, text: 'final'), TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.classStyle, text: '_RestorableDessertSelections'), + TextSpan(style: codeStyle.baseStyle, text: ' _dessertSelections '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan( + style: codeStyle.classStyle, text: '_RestorableDessertSelections'), + TextSpan(style: codeStyle.punctuationStyle, text: '();'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'final'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorableInt'), + TextSpan(style: codeStyle.baseStyle, text: ' _rowIndex '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorableInt'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.numberStyle, text: '0'), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'final'), + TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.classStyle, text: 'RestorableInt'), TextSpan(style: codeStyle.baseStyle, text: ' _rowsPerPage '), TextSpan(style: codeStyle.punctuationStyle, text: '='), @@ -18072,24 +18330,24 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.keywordStyle, text: 'final'), TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.classStyle, text: 'RestorableIntN'), - TextSpan(style: codeStyle.baseStyle, text: ' _sortColumnIndex '), + TextSpan(style: codeStyle.classStyle, text: 'RestorableBool'), + TextSpan(style: codeStyle.baseStyle, text: ' _sortAscending '), TextSpan(style: codeStyle.punctuationStyle, text: '='), TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.classStyle, text: 'RestorableIntN'), + TextSpan(style: codeStyle.classStyle, text: 'RestorableBool'), TextSpan(style: codeStyle.punctuationStyle, text: '('), - TextSpan(style: codeStyle.keywordStyle, text: 'null'), + TextSpan(style: codeStyle.keywordStyle, text: 'true'), TextSpan(style: codeStyle.punctuationStyle, text: ');'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.keywordStyle, text: 'final'), TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.classStyle, text: 'RestorableBool'), - TextSpan(style: codeStyle.baseStyle, text: ' _sortAscending '), + TextSpan(style: codeStyle.classStyle, text: 'RestorableIntN'), + TextSpan(style: codeStyle.baseStyle, text: ' _sortColumnIndex '), TextSpan(style: codeStyle.punctuationStyle, text: '='), TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.classStyle, text: 'RestorableBool'), + TextSpan(style: codeStyle.classStyle, text: 'RestorableIntN'), TextSpan(style: codeStyle.punctuationStyle, text: '('), - TextSpan(style: codeStyle.keywordStyle, text: 'true'), + TextSpan(style: codeStyle.keywordStyle, text: 'null'), TextSpan(style: codeStyle.punctuationStyle, text: ');'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.classStyle, text: '_DessertDataSource'), @@ -18125,19 +18383,29 @@ class CodeSegments { TextSpan( style: codeStyle.baseStyle, text: '\u000a registerForRestoration'), TextSpan(style: codeStyle.punctuationStyle, text: '('), - TextSpan(style: codeStyle.baseStyle, text: '_rowsPerPage'), + TextSpan(style: codeStyle.baseStyle, text: '_dessertSelections'), TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.stringStyle, text: '\u0027rows_per_page\u0027'), + TextSpan( + style: codeStyle.stringStyle, + text: '\u0027selected_row_indices\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ');'), TextSpan( style: codeStyle.baseStyle, text: '\u000a registerForRestoration'), TextSpan(style: codeStyle.punctuationStyle, text: '('), - TextSpan(style: codeStyle.baseStyle, text: '_sortColumnIndex'), + TextSpan(style: codeStyle.baseStyle, text: '_rowIndex'), TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan( - style: codeStyle.stringStyle, text: '\u0027sort_column_index\u0027'), + style: codeStyle.stringStyle, text: '\u0027current_row_index\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a registerForRestoration'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '_rowsPerPage'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.stringStyle, text: '\u0027rows_per_page\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ');'), TextSpan( style: codeStyle.baseStyle, text: '\u000a registerForRestoration'), @@ -18148,6 +18416,15 @@ class CodeSegments { TextSpan( style: codeStyle.stringStyle, text: '\u0027sort_ascending\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a registerForRestoration'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '_sortColumnIndex'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, text: '\u0027sort_column_index\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), TextSpan( style: codeStyle.baseStyle, text: '\u000a\u000a _dessertsDataSource '), @@ -18393,6 +18670,22 @@ class CodeSegments { TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a _dessertsDataSource'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'updateSelectedDesserts'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '_dessertSelections'), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a _dessertsDataSource'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'addListener'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan( + style: codeStyle.baseStyle, + text: '_updateSelectedDessertRowListener'), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.punctuationStyle, text: '}'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '), @@ -18416,6 +18709,34 @@ class CodeSegments { TextSpan(style: codeStyle.punctuationStyle, text: '('), TextSpan(style: codeStyle.baseStyle, text: 'context'), TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a _dessertsDataSource'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'addListener'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan( + style: codeStyle.baseStyle, + text: '_updateSelectedDessertRowListener'), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'void'), + TextSpan( + style: codeStyle.baseStyle, + text: ' _updateSelectedDessertRowListener'), + TextSpan(style: codeStyle.punctuationStyle, text: '()'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a _dessertSelections'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'setDessertSelections'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '_dessertsDataSource'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: '_desserts'), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.punctuationStyle, text: '}'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '), @@ -18501,6 +18822,20 @@ class CodeSegments { TextSpan(style: codeStyle.punctuationStyle, text: '.'), TextSpan(style: codeStyle.baseStyle, text: 'dispose'), TextSpan(style: codeStyle.punctuationStyle, text: '();'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a _dessertsDataSource'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'removeListener'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan( + style: codeStyle.baseStyle, + text: '_updateSelectedDessertRowListener'), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a _dessertsDataSource'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'dispose'), + TextSpan(style: codeStyle.punctuationStyle, text: '();'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.keywordStyle, text: 'super'), TextSpan(style: codeStyle.punctuationStyle, text: '.'), @@ -18637,6 +18972,41 @@ class CodeSegments { TextSpan(style: codeStyle.punctuationStyle, text: '});'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.punctuationStyle, text: '},'), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a initialFirstRowIndex'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' _rowIndex'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a onPageChanged'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'rowIndex'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a setState'), + TextSpan(style: codeStyle.punctuationStyle, text: '(()'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a _rowIndex'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' rowIndex'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '});'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '},'), TextSpan( style: codeStyle.baseStyle, text: '\u000a sortColumnIndex'), @@ -19087,46 +19457,49 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.classStyle, text: '_Dessert'), TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.keywordStyle, text: 'this'), TextSpan(style: codeStyle.punctuationStyle, text: '.'), TextSpan(style: codeStyle.baseStyle, text: 'name'), TextSpan(style: codeStyle.punctuationStyle, text: ','), - TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.keywordStyle, text: 'this'), TextSpan(style: codeStyle.punctuationStyle, text: '.'), TextSpan(style: codeStyle.baseStyle, text: 'calories'), TextSpan(style: codeStyle.punctuationStyle, text: ','), - TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.keywordStyle, text: 'this'), TextSpan(style: codeStyle.punctuationStyle, text: '.'), TextSpan(style: codeStyle.baseStyle, text: 'fat'), TextSpan(style: codeStyle.punctuationStyle, text: ','), - TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.keywordStyle, text: 'this'), TextSpan(style: codeStyle.punctuationStyle, text: '.'), TextSpan(style: codeStyle.baseStyle, text: 'carbs'), TextSpan(style: codeStyle.punctuationStyle, text: ','), - TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.keywordStyle, text: 'this'), TextSpan(style: codeStyle.punctuationStyle, text: '.'), TextSpan(style: codeStyle.baseStyle, text: 'protein'), TextSpan(style: codeStyle.punctuationStyle, text: ','), - TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.keywordStyle, text: 'this'), TextSpan(style: codeStyle.punctuationStyle, text: '.'), TextSpan(style: codeStyle.baseStyle, text: 'sodium'), TextSpan(style: codeStyle.punctuationStyle, text: ','), - TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.keywordStyle, text: 'this'), TextSpan(style: codeStyle.punctuationStyle, text: '.'), TextSpan(style: codeStyle.baseStyle, text: 'calcium'), TextSpan(style: codeStyle.punctuationStyle, text: ','), - TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.keywordStyle, text: 'this'), TextSpan(style: codeStyle.punctuationStyle, text: '.'), TextSpan(style: codeStyle.baseStyle, text: 'iron'), - TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '), TextSpan(style: codeStyle.keywordStyle, text: 'final'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.classStyle, text: 'String'), @@ -19174,7 +19547,7 @@ class CodeSegments { TextSpan(style: codeStyle.keywordStyle, text: 'int'), TextSpan(style: codeStyle.baseStyle, text: ' iron'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.keywordStyle, text: 'bool'), TextSpan(style: codeStyle.baseStyle, text: ' selected '), TextSpan(style: codeStyle.punctuationStyle, text: '='), @@ -20366,6 +20739,98 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.numberStyle, text: '0'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'void'), + TextSpan(style: codeStyle.baseStyle, text: ' updateSelectedDesserts'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan( + style: codeStyle.classStyle, text: '_RestorableDessertSelections'), + TextSpan(style: codeStyle.baseStyle, text: ' selectedRows'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a _selectedCount '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.numberStyle, text: '0'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'for'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.keywordStyle, text: 'var'), + TextSpan(style: codeStyle.baseStyle, text: ' i '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.numberStyle, text: '0'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: ' i '), + TextSpan(style: codeStyle.punctuationStyle, text: '<'), + TextSpan(style: codeStyle.baseStyle, text: ' _desserts'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'length'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: ' i '), + TextSpan(style: codeStyle.punctuationStyle, text: '+='), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.numberStyle, text: '1'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'var'), + TextSpan(style: codeStyle.baseStyle, text: ' dessert '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' _desserts'), + TextSpan(style: codeStyle.punctuationStyle, text: '['), + TextSpan(style: codeStyle.baseStyle, text: 'i'), + TextSpan(style: codeStyle.punctuationStyle, text: '];'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'if'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'selectedRows'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'isSelected'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'i'), + TextSpan(style: codeStyle.punctuationStyle, text: '))'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a dessert'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'selected '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'true'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a _selectedCount '), + TextSpan(style: codeStyle.punctuationStyle, text: '+='), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.numberStyle, text: '1'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'else'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a dessert'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'selected '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'false'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a notifyListeners'), + TextSpan(style: codeStyle.punctuationStyle, text: '();'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '}'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '), TextSpan(style: codeStyle.keywordStyle, text: '@override'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), diff --git a/lib/demos/material/data_table_demo.dart b/lib/demos/material/data_table_demo.dart index dc9981a6f7..0c9233652d 100644 --- a/lib/demos/material/data_table_demo.dart +++ b/lib/demos/material/data_table_demo.dart @@ -17,11 +17,55 @@ class DataTableDemo extends StatefulWidget { _DataTableDemoState createState() => _DataTableDemoState(); } +class _RestorableDessertSelections extends RestorableProperty> { + Set _dessertSelections = {}; + + /// Returns whether or not a dessert row is selected by index. + bool isSelected(int index) => _dessertSelections.contains(index); + + /// Takes a list of [_Dessert]s and saves the row indices of selected rows + /// into a [Set]. + void setDessertSelections(List<_Dessert> desserts) { + final updatedSet = {}; + for (var i = 0; i < desserts.length; i += 1) { + var dessert = desserts[i]; + if (dessert.selected) { + updatedSet.add(i); + } + } + _dessertSelections = updatedSet; + notifyListeners(); + } + + @override + Set createDefaultValue() => _dessertSelections; + + @override + Set fromPrimitives(Object data) { + final selectedItemIndices = data as List; + _dessertSelections = { + ...selectedItemIndices.map((dynamic id) => id as int), + }; + return _dessertSelections; + } + + @override + void initWithValue(Set value) { + _dessertSelections = value; + } + + @override + Object toPrimitives() => _dessertSelections.toList(); +} + class _DataTableDemoState extends State with RestorationMixin { + final _RestorableDessertSelections _dessertSelections = + _RestorableDessertSelections(); + final RestorableInt _rowIndex = RestorableInt(0); final RestorableInt _rowsPerPage = RestorableInt(PaginatedDataTable.defaultRowsPerPage); - final RestorableIntN _sortColumnIndex = RestorableIntN(null); final RestorableBool _sortAscending = RestorableBool(true); + final RestorableIntN _sortColumnIndex = RestorableIntN(null); _DessertDataSource _dessertsDataSource; @override @@ -29,9 +73,11 @@ class _DataTableDemoState extends State with RestorationMixin { @override void restoreState(RestorationBucket oldBucket, bool initialRestore) { + registerForRestoration(_dessertSelections, 'selected_row_indices'); + registerForRestoration(_rowIndex, 'current_row_index'); registerForRestoration(_rowsPerPage, 'rows_per_page'); - registerForRestoration(_sortColumnIndex, 'sort_column_index'); registerForRestoration(_sortAscending, 'sort_ascending'); + registerForRestoration(_sortColumnIndex, 'sort_column_index'); _dessertsDataSource ??= _DessertDataSource(context); switch (_sortColumnIndex.value) { @@ -60,12 +106,19 @@ class _DataTableDemoState extends State with RestorationMixin { _dessertsDataSource._sort((d) => d.iron, _sortAscending.value); break; } + _dessertsDataSource.updateSelectedDesserts(_dessertSelections); + _dessertsDataSource.addListener(_updateSelectedDessertRowListener); } @override void didChangeDependencies() { super.didChangeDependencies(); _dessertsDataSource ??= _DessertDataSource(context); + _dessertsDataSource.addListener(_updateSelectedDessertRowListener); + } + + void _updateSelectedDessertRowListener() { + _dessertSelections.setDessertSelections(_dessertsDataSource._desserts); } void _sort( @@ -85,6 +138,8 @@ class _DataTableDemoState extends State with RestorationMixin { _rowsPerPage.dispose(); _sortColumnIndex.dispose(); _sortAscending.dispose(); + _dessertsDataSource.removeListener(_updateSelectedDessertRowListener); + _dessertsDataSource.dispose(); super.dispose(); } @@ -109,6 +164,12 @@ class _DataTableDemoState extends State with RestorationMixin { _rowsPerPage.value = value; }); }, + initialFirstRowIndex: _rowIndex.value, + onPageChanged: (rowIndex) { + setState(() { + _rowIndex.value = rowIndex; + }); + }, sortColumnIndex: _sortColumnIndex.value, sortAscending: _sortAscending.value, onSelectAll: _dessertsDataSource._selectAll, @@ -171,8 +232,17 @@ class _DataTableDemoState extends State with RestorationMixin { } class _Dessert { - _Dessert(this.name, this.calories, this.fat, this.carbs, this.protein, - this.sodium, this.calcium, this.iron); + _Dessert( + this.name, + this.calories, + this.fat, + this.carbs, + this.protein, + this.sodium, + this.calcium, + this.iron, + ); + final String name; final int calories; final double fat; @@ -181,7 +251,6 @@ class _Dessert { final int sodium; final int calcium; final int iron; - bool selected = false; } @@ -547,6 +616,19 @@ class _DessertDataSource extends DataTableSource { } int _selectedCount = 0; + void updateSelectedDesserts(_RestorableDessertSelections selectedRows) { + _selectedCount = 0; + for (var i = 0; i < _desserts.length; i += 1) { + var dessert = _desserts[i]; + if (selectedRows.isSelected(i)) { + dessert.selected = true; + _selectedCount += 1; + } else { + dessert.selected = false; + } + } + notifyListeners(); + } @override DataRow getRow(int index) {