From 86b2ac2f3491ab1d10236da73588f2250bacc274 Mon Sep 17 00:00:00 2001 From: Shi-Hao Hong Date: Sun, 6 Dec 2020 21:57:31 +0800 Subject: [PATCH] Restorable Material Code Samples - Part 3/? (#382) * State restorable navigation rail * State restorable selection controls demo * State restorable sliders * State restorable tabs * TextFormField TODO * RestorableBoonN TODO --- lib/codeviewer/code_segments.dart | 1170 +++++++++++++++-- lib/demos/material/navigation_drawer.dart | 4 +- lib/demos/material/navigation_rail_demo.dart | 18 +- .../material/selection_controls_demo.dart | 35 +- lib/demos/material/sliders_demo.dart | 101 +- lib/demos/material/tabs_demo.dart | 173 ++- lib/demos/material/text_field_demo.dart | 2 + 7 files changed, 1303 insertions(+), 200 deletions(-) diff --git a/lib/codeviewer/code_segments.dart b/lib/codeviewer/code_segments.dart index b0d9f98805..6cc414ccaa 100644 --- a/lib/codeviewer/code_segments.dart +++ b/lib/codeviewer/code_segments.dart @@ -17095,28 +17095,109 @@ class CodeSegments { TextSpan(style: codeStyle.classStyle, text: '_CustomSliders'), TextSpan(style: codeStyle.punctuationStyle, text: '>'), TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'with'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorationMixin'), + TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.punctuationStyle, text: '{'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), - TextSpan(style: codeStyle.keywordStyle, text: 'double'), + TextSpan(style: codeStyle.keywordStyle, text: 'final'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorableDouble'), + TextSpan( + style: codeStyle.baseStyle, text: ' _continuousStartCustomValue '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorableDouble'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.numberStyle, text: '40'), + 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: 'RestorableDouble'), + TextSpan(style: codeStyle.baseStyle, text: ' _continuousEndCustomValue '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorableDouble'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.numberStyle, text: '160'), + 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: 'RestorableDouble'), TextSpan(style: codeStyle.baseStyle, text: ' _discreteCustomValue '), TextSpan(style: codeStyle.punctuationStyle, text: '='), TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorableDouble'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), TextSpan(style: codeStyle.numberStyle, text: '25'), + 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: 'String'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'get'), + TextSpan(style: codeStyle.baseStyle, text: ' restorationId '), + TextSpan(style: codeStyle.punctuationStyle, text: '=>'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: '\u0027custom_sliders_demo\u0027'), 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: 'RangeValues'), - TextSpan(style: codeStyle.baseStyle, text: ' _continuousCustomValues '), - TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.keywordStyle, text: 'void'), + TextSpan(style: codeStyle.baseStyle, text: ' restoreState'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.classStyle, text: 'RestorationBucket'), + TextSpan(style: codeStyle.baseStyle, text: ' oldBucket'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.keywordStyle, text: 'const'), + TextSpan(style: codeStyle.keywordStyle, text: 'bool'), + TextSpan(style: codeStyle.baseStyle, text: ' initialRestore'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.classStyle, text: 'RangeValues'), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a registerForRestoration'), TextSpan(style: codeStyle.punctuationStyle, text: '('), - TextSpan(style: codeStyle.numberStyle, text: '40'), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a _continuousStartCustomValue'), TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.numberStyle, text: '160'), + TextSpan( + style: codeStyle.stringStyle, + text: '\u0027continuous_start_custom_value\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a registerForRestoration'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a _continuousEndCustomValue'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: '\u0027continuous_end_custom_value\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a registerForRestoration'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '_discreteCustomValue'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: '\u0027discrete_custom_value\u0027'), 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 '), @@ -17130,6 +17211,27 @@ class CodeSegments { TextSpan(style: codeStyle.punctuationStyle, text: '{'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.keywordStyle, text: 'final'), + TextSpan(style: codeStyle.baseStyle, text: ' customRangeValue '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RangeValues'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a _continuousStartCustomValue'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a _continuousEndCustomValue'), + 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 '), + TextSpan(style: codeStyle.keywordStyle, text: 'final'), TextSpan(style: codeStyle.baseStyle, text: ' theme '), TextSpan(style: codeStyle.punctuationStyle, text: '='), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -17348,6 +17450,8 @@ class CodeSegments { style: codeStyle.baseStyle, text: '\u000a value'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' _discreteCustomValue'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value'), TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: '\u000a min'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), @@ -17390,7 +17494,7 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan( style: codeStyle.stringStyle, - text: '\u0027\u0024{_discreteCustomValue.round()}\u0027'), + text: '\u0027\u0024{_discreteCustomValue.value.round()}\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan( style: codeStyle.baseStyle, @@ -17410,7 +17514,9 @@ class CodeSegments { TextSpan(style: codeStyle.punctuationStyle, text: '{'), TextSpan( style: codeStyle.baseStyle, - text: '\u000a _discreteCustomValue '), + text: '\u000a _discreteCustomValue'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value '), TextSpan(style: codeStyle.punctuationStyle, text: '='), TextSpan(style: codeStyle.baseStyle, text: ' value'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), @@ -17563,7 +17669,7 @@ class CodeSegments { TextSpan( style: codeStyle.baseStyle, text: '\u000a values'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), - TextSpan(style: codeStyle.baseStyle, text: ' _continuousCustomValues'), + TextSpan(style: codeStyle.baseStyle, text: ' customRangeValue'), TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: '\u000a min'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), @@ -17593,9 +17699,23 @@ class CodeSegments { TextSpan(style: codeStyle.punctuationStyle, text: '{'), TextSpan( style: codeStyle.baseStyle, - text: '\u000a _continuousCustomValues '), + text: '\u000a _continuousStartCustomValue'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' values'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'start'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a _continuousEndCustomValue'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value '), TextSpan(style: codeStyle.punctuationStyle, text: '='), TextSpan(style: codeStyle.baseStyle, text: ' values'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'end'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.punctuationStyle, text: '});'), @@ -26845,11 +26965,11 @@ class CodeSegments { TextSpan( style: codeStyle.commentStyle, text: - '// Pressing the Navigation Drawer button the left of Appbar to show'), + '// Press the Navigation Drawer button to the left of AppBar to show'), TextSpan(style: codeStyle.baseStyle, text: '\u000a'), TextSpan( style: codeStyle.commentStyle, - text: '// a simple Drawer with Two items.'), + text: '// a simple Drawer with two items.'), TextSpan(style: codeStyle.baseStyle, text: '\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -27221,17 +27341,62 @@ class CodeSegments { TextSpan(style: codeStyle.classStyle, text: 'NavRailDemo'), TextSpan(style: codeStyle.punctuationStyle, text: '>'), TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'with'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorationMixin'), + TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.punctuationStyle, text: '{'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), - TextSpan(style: codeStyle.keywordStyle, text: 'int'), + TextSpan(style: codeStyle.keywordStyle, text: 'final'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorableInt'), TextSpan(style: codeStyle.baseStyle, text: ' _selectedIndex '), 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\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: '@override'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'String'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'get'), + TextSpan(style: codeStyle.baseStyle, text: ' restorationId '), + TextSpan(style: codeStyle.punctuationStyle, text: '=>'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.stringStyle, text: '\u0027nav_rail_demo\u0027'), 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: ' restoreState'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.classStyle, text: 'RestorationBucket'), + TextSpan(style: codeStyle.baseStyle, text: ' oldBucket'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'bool'), + TextSpan(style: codeStyle.baseStyle, text: ' initialRestore'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a registerForRestoration'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '_selectedIndex'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, text: '\u0027selected_index\u0027'), + 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: 'Widget'), TextSpan(style: codeStyle.baseStyle, text: ' build'), TextSpan(style: codeStyle.punctuationStyle, text: '('), @@ -27358,6 +27523,8 @@ class CodeSegments { style: codeStyle.baseStyle, text: '\u000a selectedIndex'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' _selectedIndex'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value'), TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan( style: codeStyle.baseStyle, @@ -27376,7 +27543,9 @@ class CodeSegments { TextSpan(style: codeStyle.punctuationStyle, text: '{'), TextSpan( style: codeStyle.baseStyle, - text: '\u000a _selectedIndex '), + text: '\u000a _selectedIndex'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value '), TextSpan(style: codeStyle.punctuationStyle, text: '='), TextSpan(style: codeStyle.baseStyle, text: ' index'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), @@ -27571,6 +27740,8 @@ class CodeSegments { text: '\u000a selectedItem'), TextSpan(style: codeStyle.punctuationStyle, text: '['), TextSpan(style: codeStyle.baseStyle, text: '_selectedIndex'), + 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: '),'), @@ -31909,62 +32080,189 @@ class CodeSegments { TextSpan(style: codeStyle.classStyle, text: '_RangeSliders'), TextSpan(style: codeStyle.punctuationStyle, text: '>'), TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'with'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorationMixin'), + TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.punctuationStyle, text: '{'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), - TextSpan(style: codeStyle.classStyle, text: 'RangeValues'), - TextSpan(style: codeStyle.baseStyle, text: ' _continuousValues '), - TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.keywordStyle, text: 'final'), TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.keywordStyle, text: 'const'), + TextSpan(style: codeStyle.classStyle, text: 'RestorableDouble'), + TextSpan(style: codeStyle.baseStyle, text: ' _continuousStartValue '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.classStyle, text: 'RangeValues'), + TextSpan(style: codeStyle.classStyle, text: 'RestorableDouble'), TextSpan(style: codeStyle.punctuationStyle, text: '('), TextSpan(style: codeStyle.numberStyle, text: '25'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), + 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: 'RestorableDouble'), + TextSpan(style: codeStyle.baseStyle, text: ' _continuousEndValue '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorableDouble'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), TextSpan(style: codeStyle.numberStyle, text: '75'), TextSpan(style: codeStyle.punctuationStyle, text: ');'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), - TextSpan(style: codeStyle.classStyle, text: 'RangeValues'), - TextSpan(style: codeStyle.baseStyle, text: ' _discreteValues '), - TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.keywordStyle, text: 'final'), TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.keywordStyle, text: 'const'), + TextSpan(style: codeStyle.classStyle, text: 'RestorableDouble'), + TextSpan(style: codeStyle.baseStyle, text: ' _discreteStartValue '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.classStyle, text: 'RangeValues'), + TextSpan(style: codeStyle.classStyle, text: 'RestorableDouble'), TextSpan(style: codeStyle.punctuationStyle, text: '('), TextSpan(style: codeStyle.numberStyle, text: '40'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), + 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: 'RestorableDouble'), + TextSpan(style: codeStyle.baseStyle, text: ' _discreteEndValue '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorableDouble'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), TextSpan(style: codeStyle.numberStyle, text: '120'), 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: 'Widget'), - TextSpan(style: codeStyle.baseStyle, text: ' build'), + TextSpan(style: codeStyle.classStyle, text: 'String'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'get'), + TextSpan(style: codeStyle.baseStyle, text: ' restorationId '), + TextSpan(style: codeStyle.punctuationStyle, text: '=>'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, text: '\u0027range_sliders_demo\u0027'), + 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: ' restoreState'), TextSpan(style: codeStyle.punctuationStyle, text: '('), - TextSpan(style: codeStyle.classStyle, text: 'BuildContext'), - TextSpan(style: codeStyle.baseStyle, text: ' context'), + TextSpan(style: codeStyle.classStyle, text: 'RestorationBucket'), + TextSpan(style: codeStyle.baseStyle, text: ' oldBucket'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'bool'), + TextSpan(style: codeStyle.baseStyle, text: ' initialRestore'), 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: 'return'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a registerForRestoration'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '_continuousStartValue'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.classStyle, text: 'Padding'), + TextSpan( + style: codeStyle.stringStyle, + text: '\u0027continuous_start_value\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a registerForRestoration'), TextSpan(style: codeStyle.punctuationStyle, text: '('), - TextSpan(style: codeStyle.baseStyle, text: '\u000a padding'), - TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: '_continuousEndValue'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.keywordStyle, text: 'const'), + TextSpan( + style: codeStyle.stringStyle, + text: '\u0027continuous_end_value\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a registerForRestoration'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '_discreteStartValue'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.classStyle, text: 'EdgeInsets'), - TextSpan(style: codeStyle.punctuationStyle, text: '.'), - TextSpan(style: codeStyle.baseStyle, text: 'symmetric'), + TextSpan( + style: codeStyle.stringStyle, + text: '\u0027discrete_start_value\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a registerForRestoration'), TextSpan(style: codeStyle.punctuationStyle, text: '('), - TextSpan(style: codeStyle.baseStyle, text: 'horizontal'), - TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: '_discreteEndValue'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, text: '\u0027discrete_end_value\u0027'), + 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: 'Widget'), + TextSpan(style: codeStyle.baseStyle, text: ' build'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.classStyle, text: 'BuildContext'), + TextSpan(style: codeStyle.baseStyle, text: ' context'), + 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: ' _continuousValues '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RangeValues'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a _continuousStartValue'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a _continuousEndValue'), + 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 '), + TextSpan(style: codeStyle.keywordStyle, text: 'final'), + TextSpan(style: codeStyle.baseStyle, text: ' _discreteValues '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RangeValues'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a _discreteStartValue'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a _discreteEndValue'), + 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: 'return'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'Padding'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '\u000a padding'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'const'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'EdgeInsets'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'symmetric'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'horizontal'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.numberStyle, text: '40'), TextSpan(style: codeStyle.punctuationStyle, text: '),'), @@ -32034,9 +32332,23 @@ class CodeSegments { TextSpan(style: codeStyle.punctuationStyle, text: '{'), TextSpan( style: codeStyle.baseStyle, - text: '\u000a _continuousValues '), + text: '\u000a _continuousStartValue'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' values'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'start'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a _continuousEndValue'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value '), TextSpan(style: codeStyle.punctuationStyle, text: '='), TextSpan(style: codeStyle.baseStyle, text: ' values'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'end'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.punctuationStyle, text: '});'), @@ -32152,9 +32464,23 @@ class CodeSegments { TextSpan(style: codeStyle.punctuationStyle, text: '{'), TextSpan( style: codeStyle.baseStyle, - text: '\u000a _discreteValues '), + text: '\u000a _discreteStartValue'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' values'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'start'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a _discreteEndValue'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value '), TextSpan(style: codeStyle.punctuationStyle, text: '='), TextSpan(style: codeStyle.baseStyle, text: ' values'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'end'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.punctuationStyle, text: '});'), @@ -32257,6 +32583,19 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.punctuationStyle, text: '{'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan( + style: codeStyle.commentStyle, + text: + '// TODO(shihaohong): Introduce RestorableBoolN into the framework'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan( + style: codeStyle.commentStyle, + text: + '// to allow checkboxes to be properly state restorable (null value has'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan( + style: codeStyle.commentStyle, text: '// meaning in checkboxes).'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.keywordStyle, text: 'bool'), TextSpan(style: codeStyle.baseStyle, text: ' checkboxValueA '), TextSpan(style: codeStyle.punctuationStyle, text: '='), @@ -32485,15 +32824,59 @@ class CodeSegments { TextSpan(style: codeStyle.classStyle, text: '_RadioDemo'), TextSpan(style: codeStyle.punctuationStyle, text: '>'), TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'with'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorationMixin'), + TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.punctuationStyle, text: '{'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), - TextSpan(style: codeStyle.keywordStyle, text: 'int'), + TextSpan(style: codeStyle.keywordStyle, text: 'final'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorableInt'), TextSpan(style: codeStyle.baseStyle, text: ' radioValue '), 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\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: '@override'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'String'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'get'), + TextSpan(style: codeStyle.baseStyle, text: ' restorationId '), + TextSpan(style: codeStyle.punctuationStyle, text: '=>'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.stringStyle, text: '\u0027radio_demo\u0027'), 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: ' restoreState'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.classStyle, text: 'RestorationBucket'), + TextSpan(style: codeStyle.baseStyle, text: ' oldBucket'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'bool'), + TextSpan(style: codeStyle.baseStyle, text: ' initialRestore'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a registerForRestoration'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'radioValue'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.stringStyle, text: '\u0027radio_value\u0027'), + 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: ' handleRadioValueChanged'), TextSpan(style: codeStyle.punctuationStyle, text: '('), @@ -32506,7 +32889,9 @@ class CodeSegments { TextSpan(style: codeStyle.punctuationStyle, text: '(()'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.punctuationStyle, text: '{'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a radioValue '), + TextSpan(style: codeStyle.baseStyle, text: '\u000a radioValue'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value '), TextSpan(style: codeStyle.punctuationStyle, text: '='), TextSpan(style: codeStyle.baseStyle, text: ' value'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), @@ -32578,6 +32963,8 @@ class CodeSegments { style: codeStyle.baseStyle, text: '\u000a groupValue'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' radioValue'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value'), TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan( style: codeStyle.baseStyle, text: '\u000a onChanged'), @@ -32664,17 +33051,59 @@ class CodeSegments { TextSpan(style: codeStyle.classStyle, text: '_SwitchDemo'), TextSpan(style: codeStyle.punctuationStyle, text: '>'), TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'with'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorationMixin'), + TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.punctuationStyle, text: '{'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), - TextSpan(style: codeStyle.keywordStyle, text: 'bool'), + TextSpan(style: codeStyle.classStyle, text: 'RestorableBool'), TextSpan(style: codeStyle.baseStyle, text: ' switchValue '), TextSpan(style: codeStyle.punctuationStyle, text: '='), TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorableBool'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), TextSpan(style: codeStyle.keywordStyle, text: 'false'), + 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: 'String'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'get'), + TextSpan(style: codeStyle.baseStyle, text: ' restorationId '), + TextSpan(style: codeStyle.punctuationStyle, text: '=>'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.stringStyle, text: '\u0027switch_demo\u0027'), 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: ' restoreState'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.classStyle, text: 'RestorationBucket'), + TextSpan(style: codeStyle.baseStyle, text: ' oldBucket'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'bool'), + TextSpan(style: codeStyle.baseStyle, text: ' initialRestore'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a registerForRestoration'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'switchValue'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.stringStyle, text: '\u0027switch_value\u0027'), + 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: 'Widget'), TextSpan(style: codeStyle.baseStyle, text: ' build'), TextSpan(style: codeStyle.punctuationStyle, text: '('), @@ -32718,6 +33147,8 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: '\u000a value'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' switchValue'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value'), TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: '\u000a onChanged'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), @@ -32732,7 +33163,9 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.punctuationStyle, text: '{'), TextSpan( - style: codeStyle.baseStyle, text: '\u000a switchValue '), + style: codeStyle.baseStyle, text: '\u000a switchValue'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value '), TextSpan(style: codeStyle.punctuationStyle, text: '='), TextSpan(style: codeStyle.baseStyle, text: ' value'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), @@ -36325,24 +36758,82 @@ class CodeSegments { TextSpan(style: codeStyle.classStyle, text: '_Sliders'), TextSpan(style: codeStyle.punctuationStyle, text: '>'), TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'with'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorationMixin'), + TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.punctuationStyle, text: '{'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), - TextSpan(style: codeStyle.keywordStyle, text: 'double'), + TextSpan(style: codeStyle.keywordStyle, text: 'final'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorableDouble'), TextSpan(style: codeStyle.baseStyle, text: ' _continuousValue '), TextSpan(style: codeStyle.punctuationStyle, text: '='), TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorableDouble'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), TextSpan(style: codeStyle.numberStyle, text: '25'), - TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), - TextSpan(style: codeStyle.keywordStyle, text: 'double'), + TextSpan(style: codeStyle.keywordStyle, text: 'final'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorableDouble'), TextSpan(style: codeStyle.baseStyle, text: ' _discreteValue '), TextSpan(style: codeStyle.punctuationStyle, text: '='), TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorableDouble'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), TextSpan(style: codeStyle.numberStyle, text: '20'), + 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: 'String'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'get'), + TextSpan(style: codeStyle.baseStyle, text: ' restorationId '), + TextSpan(style: codeStyle.punctuationStyle, text: '=>'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.stringStyle, text: '\u0027slider_demo\u0027'), 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: ' restoreState'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.classStyle, text: 'RestorationBucket'), + TextSpan(style: codeStyle.baseStyle, text: ' oldBucket'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'bool'), + TextSpan(style: codeStyle.baseStyle, text: ' initialRestore'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a registerForRestoration'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '_continuousValue'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, text: '\u0027continuous_value\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a registerForRestoration'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '_discreteValue'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, text: '\u0027discrete_value\u0027'), + 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: 'Widget'), TextSpan(style: codeStyle.baseStyle, text: ' build'), TextSpan(style: codeStyle.punctuationStyle, text: '('), @@ -36485,9 +36976,13 @@ class CodeSegments { TextSpan(style: codeStyle.keywordStyle, text: 'null'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.punctuationStyle, text: '&&'), - TextSpan(style: codeStyle.baseStyle, text: ' newValue '), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a newValue '), TextSpan(style: codeStyle.punctuationStyle, text: '!='), TextSpan(style: codeStyle.baseStyle, text: ' _continuousValue'), + 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: '{'), @@ -36499,9 +36994,13 @@ class CodeSegments { TextSpan(style: codeStyle.punctuationStyle, text: '{'), TextSpan( style: codeStyle.baseStyle, - text: '\u000a _continuousValue '), - TextSpan(style: codeStyle.punctuationStyle, text: '='), - TextSpan(style: codeStyle.baseStyle, text: ' newValue'), + text: '\u000a _continuousValue'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan( + style: codeStyle.baseStyle, + text: '\u000a newValue'), TextSpan(style: codeStyle.punctuationStyle, text: '.'), TextSpan(style: codeStyle.baseStyle, text: 'clamp'), TextSpan(style: codeStyle.punctuationStyle, text: '('), @@ -36544,6 +37043,8 @@ class CodeSegments { TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' _continuousValue'), TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), TextSpan(style: codeStyle.baseStyle, text: 'toStringAsFixed'), TextSpan(style: codeStyle.punctuationStyle, text: '('), TextSpan(style: codeStyle.numberStyle, text: '0'), @@ -36562,6 +37063,8 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: '\u000a value'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' _continuousValue'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value'), TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: '\u000a min'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), @@ -36589,7 +37092,9 @@ class CodeSegments { TextSpan(style: codeStyle.punctuationStyle, text: '{'), TextSpan( style: codeStyle.baseStyle, - text: '\u000a _continuousValue '), + text: '\u000a _continuousValue'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value '), TextSpan(style: codeStyle.punctuationStyle, text: '='), TextSpan(style: codeStyle.baseStyle, text: ' value'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), @@ -36649,6 +37154,8 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: '\u000a value'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' _discreteValue'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value'), TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: '\u000a min'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), @@ -36670,6 +37177,8 @@ class CodeSegments { TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' _discreteValue'), TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), TextSpan(style: codeStyle.baseStyle, text: 'round'), TextSpan(style: codeStyle.punctuationStyle, text: '().'), TextSpan(style: codeStyle.baseStyle, text: 'toString'), @@ -36690,7 +37199,9 @@ class CodeSegments { TextSpan(style: codeStyle.punctuationStyle, text: '{'), TextSpan( style: codeStyle.baseStyle, - text: '\u000a _discreteValue '), + text: '\u000a _discreteValue'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value '), TextSpan(style: codeStyle.punctuationStyle, text: '='), TextSpan(style: codeStyle.baseStyle, text: ' value'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), @@ -37000,10 +37511,187 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.keywordStyle, text: 'extends'), TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.classStyle, text: 'StatelessWidget'), + TextSpan(style: codeStyle.classStyle, text: 'StatefulWidget'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: '@override'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan( + style: codeStyle.classStyle, text: '__TabsNonScrollableDemoState'), + TextSpan(style: codeStyle.baseStyle, text: ' createState'), + TextSpan(style: codeStyle.punctuationStyle, text: '()'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '=>'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.classStyle, text: '__TabsNonScrollableDemoState'), + 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: '__TabsNonScrollableDemoState'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'extends'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'State'), + TextSpan(style: codeStyle.punctuationStyle, text: '<'), + TextSpan(style: codeStyle.classStyle, text: '_TabsNonScrollableDemo'), + TextSpan(style: codeStyle.punctuationStyle, text: '>'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'with'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.classStyle, text: 'SingleTickerProviderStateMixin'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorationMixin'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'TabController'), + TextSpan(style: codeStyle.baseStyle, text: ' _tabController'), + 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: 'RestorableInt'), + TextSpan(style: codeStyle.baseStyle, text: ' tabIndex '), + 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\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: '@override'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'String'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'get'), + TextSpan(style: codeStyle.baseStyle, text: ' restorationId '), + TextSpan(style: codeStyle.punctuationStyle, text: '=>'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: '\u0027tab_non_scrollable_demo\u0027'), + 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: ' restoreState'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.classStyle, text: 'RestorationBucket'), + TextSpan(style: codeStyle.baseStyle, text: ' oldBucket'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'bool'), + TextSpan(style: codeStyle.baseStyle, text: ' initialRestore'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a registerForRestoration'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'tabIndex'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.stringStyle, text: '\u0027tab_index\u0027'), + 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: ' initState'), + TextSpan(style: codeStyle.punctuationStyle, text: '()'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a _tabController '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'TabController'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '\u000a initialIndex'), + 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 length'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.numberStyle, text: '3'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: '\u000a vsync'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'this'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a _tabController'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'addListener'), + TextSpan(style: codeStyle.punctuationStyle, text: '(()'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan( + style: codeStyle.commentStyle, + text: + '// When the tab controller\u0027s value is updated, make sure to update the'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan( + style: codeStyle.commentStyle, + text: '// tab index value, which is state restorable.'), + 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 tabIndex'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' _tabController'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'index'), + 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 '), + TextSpan(style: codeStyle.keywordStyle, text: 'super'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'initState'), + 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: ' dispose'), + TextSpan(style: codeStyle.punctuationStyle, text: '()'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a _tabController'), + 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: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'dispose'), + 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: 'Widget'), @@ -37015,6 +37703,39 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.punctuationStyle, text: '{'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan( + style: codeStyle.commentStyle, + text: + '// Ensures that the tab controller\u0027s index is updated with the'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan( + style: codeStyle.commentStyle, + text: '// state restorable tab index value.'), + 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: '_tabController'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'index '), + TextSpan(style: codeStyle.punctuationStyle, text: '!='), + TextSpan(style: codeStyle.baseStyle, text: ' tabIndex'), + 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 _tabController'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'index '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' tabIndex'), + 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: 'final'), TextSpan(style: codeStyle.baseStyle, text: ' tabs '), TextSpan(style: codeStyle.punctuationStyle, text: '='), @@ -37052,36 +37773,26 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '), TextSpan(style: codeStyle.keywordStyle, text: 'return'), TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.classStyle, text: 'DefaultTabController'), - TextSpan(style: codeStyle.punctuationStyle, text: '('), - TextSpan(style: codeStyle.baseStyle, text: '\u000a length'), - TextSpan(style: codeStyle.punctuationStyle, text: ':'), - TextSpan(style: codeStyle.baseStyle, text: ' tabs'), - TextSpan(style: codeStyle.punctuationStyle, text: '.'), - TextSpan(style: codeStyle.baseStyle, text: 'length'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), - TextSpan(style: codeStyle.baseStyle, text: '\u000a child'), - TextSpan(style: codeStyle.punctuationStyle, text: ':'), - TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.classStyle, text: 'Scaffold'), TextSpan(style: codeStyle.punctuationStyle, text: '('), - TextSpan(style: codeStyle.baseStyle, text: '\u000a appBar'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a appBar'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.classStyle, text: 'AppBar'), TextSpan(style: codeStyle.punctuationStyle, text: '('), TextSpan( style: codeStyle.baseStyle, - text: '\u000a automaticallyImplyLeading'), + text: '\u000a automaticallyImplyLeading'), 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 title'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a title'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.classStyle, text: 'Text'), TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.classStyle, text: 'GalleryLocalizations'), TextSpan(style: codeStyle.punctuationStyle, text: '.'), TextSpan(style: codeStyle.baseStyle, text: 'of'), @@ -37089,23 +37800,29 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: 'context'), TextSpan(style: codeStyle.punctuationStyle, text: ').'), TextSpan(style: codeStyle.baseStyle, text: 'demoTabsNonScrollingTitle'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.punctuationStyle, text: '),'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a bottom'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a bottom'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.classStyle, text: 'TabBar'), TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '\u000a controller'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' _tabController'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan( - style: codeStyle.baseStyle, text: '\u000a isScrollable'), + style: codeStyle.baseStyle, text: '\u000a isScrollable'), 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 tabs'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a tabs'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.punctuationStyle, text: '['), - TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.keywordStyle, text: 'for'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.punctuationStyle, text: '('), @@ -37121,22 +37838,26 @@ class CodeSegments { TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' tab'), 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.punctuationStyle, text: '],'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.punctuationStyle, text: '),'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a body'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '),'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a body'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.classStyle, text: 'TabBarView'), TextSpan(style: codeStyle.punctuationStyle, text: '('), - TextSpan(style: codeStyle.baseStyle, text: '\u000a children'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a controller'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' _tabController'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: '\u000a children'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.punctuationStyle, text: '['), - TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.keywordStyle, text: 'for'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.punctuationStyle, text: '('), @@ -37145,22 +37866,20 @@ class CodeSegments { TextSpan(style: codeStyle.keywordStyle, text: 'in'), TextSpan(style: codeStyle.baseStyle, text: ' tabs'), TextSpan(style: codeStyle.punctuationStyle, text: ')'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.classStyle, text: 'Center'), TextSpan(style: codeStyle.punctuationStyle, text: '('), - TextSpan(style: codeStyle.baseStyle, text: '\u000a child'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a child'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.classStyle, text: 'Text'), TextSpan(style: codeStyle.punctuationStyle, text: '('), TextSpan(style: codeStyle.baseStyle, text: 'tab'), TextSpan(style: codeStyle.punctuationStyle, text: '),'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + 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 '), - 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 '), @@ -37209,12 +37928,186 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.keywordStyle, text: 'extends'), TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.classStyle, text: 'StatelessWidget'), + TextSpan(style: codeStyle.classStyle, text: 'StatefulWidget'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.punctuationStyle, text: '{'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.keywordStyle, text: '@override'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: '__TabsScrollableDemoState'), + TextSpan(style: codeStyle.baseStyle, text: ' createState'), + TextSpan(style: codeStyle.punctuationStyle, text: '()'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '=>'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: '__TabsScrollableDemoState'), + 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: '__TabsScrollableDemoState'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'extends'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'State'), + TextSpan(style: codeStyle.punctuationStyle, text: '<'), + TextSpan(style: codeStyle.classStyle, text: '_TabsScrollableDemo'), + TextSpan(style: codeStyle.punctuationStyle, text: '>'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: 'with'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.classStyle, text: 'SingleTickerProviderStateMixin'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'RestorationMixin'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'TabController'), + TextSpan(style: codeStyle.baseStyle, text: ' _tabController'), + 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: 'RestorableInt'), + TextSpan(style: codeStyle.baseStyle, text: ' tabIndex '), + 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\u000a '), + TextSpan(style: codeStyle.keywordStyle, text: '@override'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'String'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'get'), + TextSpan(style: codeStyle.baseStyle, text: ' restorationId '), + TextSpan(style: codeStyle.punctuationStyle, text: '=>'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: '\u0027tab_scrollable_demo\u0027'), + 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: ' restoreState'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.classStyle, text: 'RestorationBucket'), + TextSpan(style: codeStyle.baseStyle, text: ' oldBucket'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'bool'), + TextSpan(style: codeStyle.baseStyle, text: ' initialRestore'), + TextSpan(style: codeStyle.punctuationStyle, text: ')'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a registerForRestoration'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'tabIndex'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.stringStyle, text: '\u0027tab_index\u0027'), + 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: ' initState'), + TextSpan(style: codeStyle.punctuationStyle, text: '()'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a _tabController '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.classStyle, text: 'TabController'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '\u000a initialIndex'), + 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 length'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.numberStyle, text: '12'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: '\u000a vsync'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.keywordStyle, text: 'this'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: ');'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a _tabController'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'addListener'), + TextSpan(style: codeStyle.punctuationStyle, text: '(()'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan( + style: codeStyle.commentStyle, + text: + '// When the tab controller\u0027s value is updated, make sure to update the'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan( + style: codeStyle.commentStyle, + text: '// tab index value, which is state restorable.'), + 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 tabIndex'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'value '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' _tabController'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'index'), + 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 '), + TextSpan(style: codeStyle.keywordStyle, text: 'super'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'initState'), + 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: ' dispose'), + TextSpan(style: codeStyle.punctuationStyle, text: '()'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan(style: codeStyle.punctuationStyle, text: '{'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a _tabController'), + 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: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'dispose'), + 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: 'Widget'), TextSpan(style: codeStyle.baseStyle, text: ' build'), TextSpan(style: codeStyle.punctuationStyle, text: '('), @@ -37224,6 +38117,39 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.punctuationStyle, text: '{'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan( + style: codeStyle.commentStyle, + text: + '// Ensures that the tab controller\u0027s index is updated with the'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan( + style: codeStyle.commentStyle, + text: '// state restorable tab index value.'), + 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: '_tabController'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'index '), + TextSpan(style: codeStyle.punctuationStyle, text: '!='), + TextSpan(style: codeStyle.baseStyle, text: ' tabIndex'), + 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 _tabController'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'index '), + TextSpan(style: codeStyle.punctuationStyle, text: '='), + TextSpan(style: codeStyle.baseStyle, text: ' tabIndex'), + 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: 'final'), TextSpan(style: codeStyle.baseStyle, text: ' tabs '), TextSpan(style: codeStyle.punctuationStyle, text: '='), @@ -37342,32 +38268,21 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '), TextSpan(style: codeStyle.keywordStyle, text: 'return'), TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.classStyle, text: 'DefaultTabController'), - TextSpan(style: codeStyle.punctuationStyle, text: '('), - TextSpan(style: codeStyle.baseStyle, text: '\u000a length'), - TextSpan(style: codeStyle.punctuationStyle, text: ':'), - TextSpan(style: codeStyle.baseStyle, text: ' tabs'), - TextSpan(style: codeStyle.punctuationStyle, text: '.'), - TextSpan(style: codeStyle.baseStyle, text: 'length'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), - TextSpan(style: codeStyle.baseStyle, text: '\u000a child'), - TextSpan(style: codeStyle.punctuationStyle, text: ':'), - TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.classStyle, text: 'Scaffold'), TextSpan(style: codeStyle.punctuationStyle, text: '('), - TextSpan(style: codeStyle.baseStyle, text: '\u000a appBar'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a appBar'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.classStyle, text: 'AppBar'), TextSpan(style: codeStyle.punctuationStyle, text: '('), TextSpan( style: codeStyle.baseStyle, - text: '\u000a automaticallyImplyLeading'), + text: '\u000a automaticallyImplyLeading'), 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 title'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a title'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.classStyle, text: 'Text'), @@ -37380,22 +38295,26 @@ class CodeSegments { TextSpan(style: codeStyle.punctuationStyle, text: ').'), TextSpan(style: codeStyle.baseStyle, text: 'demoTabsScrollingTitle'), TextSpan(style: codeStyle.punctuationStyle, text: '),'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a bottom'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a bottom'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.classStyle, text: 'TabBar'), TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: '\u000a controller'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' _tabController'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan( - style: codeStyle.baseStyle, text: '\u000a isScrollable'), + style: codeStyle.baseStyle, text: '\u000a isScrollable'), 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 tabs'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a tabs'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.punctuationStyle, text: '['), - TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.keywordStyle, text: 'for'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.punctuationStyle, text: '('), @@ -37411,22 +38330,26 @@ class CodeSegments { TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' tab'), 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.punctuationStyle, text: '],'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.punctuationStyle, text: '),'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a body'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.punctuationStyle, text: '),'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a body'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.classStyle, text: 'TabBarView'), TextSpan(style: codeStyle.punctuationStyle, text: '('), - TextSpan(style: codeStyle.baseStyle, text: '\u000a children'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a controller'), + TextSpan(style: codeStyle.punctuationStyle, text: ':'), + TextSpan(style: codeStyle.baseStyle, text: ' _tabController'), + TextSpan(style: codeStyle.punctuationStyle, text: ','), + TextSpan(style: codeStyle.baseStyle, text: '\u000a children'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.punctuationStyle, text: '['), - TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.keywordStyle, text: 'for'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.punctuationStyle, text: '('), @@ -37435,22 +38358,20 @@ class CodeSegments { TextSpan(style: codeStyle.keywordStyle, text: 'in'), TextSpan(style: codeStyle.baseStyle, text: ' tabs'), TextSpan(style: codeStyle.punctuationStyle, text: ')'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.classStyle, text: 'Center'), TextSpan(style: codeStyle.punctuationStyle, text: '('), - TextSpan(style: codeStyle.baseStyle, text: '\u000a child'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a child'), TextSpan(style: codeStyle.punctuationStyle, text: ':'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.classStyle, text: 'Text'), TextSpan(style: codeStyle.punctuationStyle, text: '('), TextSpan(style: codeStyle.baseStyle, text: 'tab'), TextSpan(style: codeStyle.punctuationStyle, text: '),'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + 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 '), - 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 '), @@ -37535,6 +38456,13 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.punctuationStyle, text: '{'), TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan( + style: codeStyle.commentStyle, + text: + '// TODO(shihaohong): Implement state restoration for TextFormField'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.commentStyle, text: '// on the framework.'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), TextSpan(style: codeStyle.keywordStyle, text: 'return'), TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan(style: codeStyle.classStyle, text: 'Scaffold'), diff --git a/lib/demos/material/navigation_drawer.dart b/lib/demos/material/navigation_drawer.dart index 5bdf3840a0..88e03d3fd3 100644 --- a/lib/demos/material/navigation_drawer.dart +++ b/lib/demos/material/navigation_drawer.dart @@ -8,8 +8,8 @@ import 'package:flutter/cupertino.dart'; // BEGIN navDrawerDemo -// Pressing the Navigation Drawer button the left of Appbar to show -// a simple Drawer with Two items. +// Press the Navigation Drawer button to the left of AppBar to show +// a simple Drawer with two items. class NavDrawerDemo extends StatelessWidget { const NavDrawerDemo({Key key}) : super(key: key); diff --git a/lib/demos/material/navigation_rail_demo.dart b/lib/demos/material/navigation_rail_demo.dart index 96e6f611dd..4756560979 100644 --- a/lib/demos/material/navigation_rail_demo.dart +++ b/lib/demos/material/navigation_rail_demo.dart @@ -14,8 +14,16 @@ class NavRailDemo extends StatefulWidget { _NavRailDemoState createState() => _NavRailDemoState(); } -class _NavRailDemoState extends State { - int _selectedIndex = 0; +class _NavRailDemoState extends State with RestorationMixin { + final RestorableInt _selectedIndex = RestorableInt(0); + + @override + String get restorationId => 'nav_rail_demo'; + + @override + void restoreState(RestorationBucket oldBucket, bool initialRestore) { + registerForRestoration(_selectedIndex, 'selected_index'); + } @override Widget build(BuildContext context) { @@ -41,10 +49,10 @@ class _NavRailDemoState extends State { child: const Icon(Icons.add), onPressed: () {}, ), - selectedIndex: _selectedIndex, + selectedIndex: _selectedIndex.value, onDestinationSelected: (index) { setState(() { - _selectedIndex = index; + _selectedIndex.value = index; }); }, labelType: NavigationRailLabelType.selected, @@ -88,7 +96,7 @@ class _NavRailDemoState extends State { Expanded( child: Center( child: Text( - selectedItem[_selectedIndex], + selectedItem[_selectedIndex.value], ), ), ), diff --git a/lib/demos/material/selection_controls_demo.dart b/lib/demos/material/selection_controls_demo.dart index c6ccb8a9d3..09402ca40c 100644 --- a/lib/demos/material/selection_controls_demo.dart +++ b/lib/demos/material/selection_controls_demo.dart @@ -64,6 +64,9 @@ class _CheckboxDemo extends StatefulWidget { } class _CheckboxDemoState extends State<_CheckboxDemo> { + // TODO(shihaohong): Introduce RestorableBoolN into the framework + // to allow checkboxes to be properly state restorable (null value has + // meaning in checkboxes). bool checkboxValueA = true; bool checkboxValueB = false; bool checkboxValueC; @@ -114,12 +117,20 @@ class _RadioDemo extends StatefulWidget { _RadioDemoState createState() => _RadioDemoState(); } -class _RadioDemoState extends State<_RadioDemo> { - int radioValue = 0; +class _RadioDemoState extends State<_RadioDemo> with RestorationMixin { + final RestorableInt radioValue = RestorableInt(0); + + @override + String get restorationId => 'radio_demo'; + + @override + void restoreState(RestorationBucket oldBucket, bool initialRestore) { + registerForRestoration(radioValue, 'radio_value'); + } void handleRadioValueChanged(int value) { setState(() { - radioValue = value; + radioValue.value = value; }); } @@ -132,7 +143,7 @@ class _RadioDemoState extends State<_RadioDemo> { for (int index = 0; index < 3; ++index) Radio( value: index, - groupValue: radioValue, + groupValue: radioValue.value, onChanged: handleRadioValueChanged, ), ], @@ -150,8 +161,16 @@ class _SwitchDemo extends StatefulWidget { _SwitchDemoState createState() => _SwitchDemoState(); } -class _SwitchDemoState extends State<_SwitchDemo> { - bool switchValue = false; +class _SwitchDemoState extends State<_SwitchDemo> with RestorationMixin { + RestorableBool switchValue = RestorableBool(false); + + @override + String get restorationId => 'switch_demo'; + + @override + void restoreState(RestorationBucket oldBucket, bool initialRestore) { + registerForRestoration(switchValue, 'switch_value'); + } @override Widget build(BuildContext context) { @@ -161,10 +180,10 @@ class _SwitchDemoState extends State<_SwitchDemo> { label: GalleryLocalizations.of(context).demoSelectionControlsSwitchTitle, child: Switch( - value: switchValue, + value: switchValue.value, onChanged: (value) { setState(() { - switchValue = value; + switchValue.value = value; }); }, ), diff --git a/lib/demos/material/sliders_demo.dart b/lib/demos/material/sliders_demo.dart index 6e3bba6af0..5a25d56905 100644 --- a/lib/demos/material/sliders_demo.dart +++ b/lib/demos/material/sliders_demo.dart @@ -59,9 +59,18 @@ class _Sliders extends StatefulWidget { _SlidersState createState() => _SlidersState(); } -class _SlidersState extends State<_Sliders> { - double _continuousValue = 25; - double _discreteValue = 20; +class _SlidersState extends State<_Sliders> with RestorationMixin { + final RestorableDouble _continuousValue = RestorableDouble(25); + final RestorableDouble _discreteValue = RestorableDouble(20); + + @override + String get restorationId => 'slider_demo'; + + @override + void restoreState(RestorationBucket oldBucket, bool initialRestore) { + registerForRestoration(_continuousValue, 'continuous_value'); + registerForRestoration(_discreteValue, 'discrete_value'); + } @override Widget build(BuildContext context) { @@ -83,26 +92,28 @@ class _SlidersState extends State<_Sliders> { textAlign: TextAlign.center, onSubmitted: (value) { final newValue = double.tryParse(value); - if (newValue != null && newValue != _continuousValue) { + if (newValue != null && + newValue != _continuousValue.value) { setState(() { - _continuousValue = newValue.clamp(0, 100) as double; + _continuousValue.value = + newValue.clamp(0, 100) as double; }); } }, keyboardType: TextInputType.number, controller: TextEditingController( - text: _continuousValue.toStringAsFixed(0), + text: _continuousValue.value.toStringAsFixed(0), ), ), ), ), Slider( - value: _continuousValue, + value: _continuousValue.value, min: 0, max: 100, onChanged: (value) { setState(() { - _continuousValue = value; + _continuousValue.value = value; }); }, ), @@ -115,14 +126,14 @@ class _SlidersState extends State<_Sliders> { mainAxisSize: MainAxisSize.min, children: [ Slider( - value: _discreteValue, + value: _discreteValue.value, min: 0, max: 200, divisions: 5, - label: _discreteValue.round().toString(), + label: _discreteValue.value.round().toString(), onChanged: (value) { setState(() { - _discreteValue = value; + _discreteValue.value = value; }); }, ), @@ -144,12 +155,34 @@ class _RangeSliders extends StatefulWidget { _RangeSlidersState createState() => _RangeSlidersState(); } -class _RangeSlidersState extends State<_RangeSliders> { - RangeValues _continuousValues = const RangeValues(25, 75); - RangeValues _discreteValues = const RangeValues(40, 120); +class _RangeSlidersState extends State<_RangeSliders> with RestorationMixin { + final RestorableDouble _continuousStartValue = RestorableDouble(25); + final RestorableDouble _continuousEndValue = RestorableDouble(75); + final RestorableDouble _discreteStartValue = RestorableDouble(40); + final RestorableDouble _discreteEndValue = RestorableDouble(120); + + @override + String get restorationId => 'range_sliders_demo'; + + @override + void restoreState(RestorationBucket oldBucket, bool initialRestore) { + registerForRestoration(_continuousStartValue, 'continuous_start_value'); + registerForRestoration(_continuousEndValue, 'continuous_end_value'); + registerForRestoration(_discreteStartValue, 'discrete_start_value'); + registerForRestoration(_discreteEndValue, 'discrete_end_value'); + } @override Widget build(BuildContext context) { + final _continuousValues = RangeValues( + _continuousStartValue.value, + _continuousEndValue.value, + ); + final _discreteValues = RangeValues( + _discreteStartValue.value, + _discreteEndValue.value, + ); + return Padding( padding: const EdgeInsets.symmetric(horizontal: 40), child: Column( @@ -164,7 +197,8 @@ class _RangeSlidersState extends State<_RangeSliders> { max: 100, onChanged: (values) { setState(() { - _continuousValues = values; + _continuousStartValue.value = values.start; + _continuousEndValue.value = values.end; }); }, ), @@ -186,7 +220,8 @@ class _RangeSlidersState extends State<_RangeSliders> { ), onChanged: (values) { setState(() { - _discreteValues = values; + _discreteStartValue.value = values.start; + _discreteEndValue.value = values.end; }); }, ), @@ -423,12 +458,29 @@ class _CustomSliders extends StatefulWidget { _CustomSlidersState createState() => _CustomSlidersState(); } -class _CustomSlidersState extends State<_CustomSliders> { - double _discreteCustomValue = 25; - RangeValues _continuousCustomValues = const RangeValues(40, 160); +class _CustomSlidersState extends State<_CustomSliders> with RestorationMixin { + final RestorableDouble _continuousStartCustomValue = RestorableDouble(40); + final RestorableDouble _continuousEndCustomValue = RestorableDouble(160); + final RestorableDouble _discreteCustomValue = RestorableDouble(25); + + @override + String get restorationId => 'custom_sliders_demo'; + + @override + void restoreState(RestorationBucket oldBucket, bool initialRestore) { + registerForRestoration( + _continuousStartCustomValue, 'continuous_start_custom_value'); + registerForRestoration( + _continuousEndCustomValue, 'continuous_end_custom_value'); + registerForRestoration(_discreteCustomValue, 'discrete_custom_value'); + } @override Widget build(BuildContext context) { + final customRangeValue = RangeValues( + _continuousStartCustomValue.value, + _continuousEndCustomValue.value, + ); final theme = Theme.of(context); return Padding( padding: const EdgeInsets.symmetric(horizontal: 40), @@ -457,16 +509,16 @@ class _CustomSlidersState extends State<_CustomSliders> { .copyWith(color: theme.colorScheme.onSurface), ), child: Slider( - value: _discreteCustomValue, + value: _discreteCustomValue.value, min: 0, max: 200, divisions: 5, semanticFormatterCallback: (value) => value.round().toString(), - label: '${_discreteCustomValue.round()}', + label: '${_discreteCustomValue.value.round()}', onChanged: (value) { setState(() { - _discreteCustomValue = value; + _discreteCustomValue.value = value; }); }, ), @@ -492,12 +544,13 @@ class _CustomSlidersState extends State<_CustomSliders> { showValueIndicator: ShowValueIndicator.never, ), child: RangeSlider( - values: _continuousCustomValues, + values: customRangeValue, min: 0, max: 200, onChanged: (values) { setState(() { - _continuousCustomValues = values; + _continuousStartCustomValue.value = values.start; + _continuousEndCustomValue.value = values.end; }); }, ), diff --git a/lib/demos/material/tabs_demo.dart b/lib/demos/material/tabs_demo.dart index bab0adff7c..bf66dcc2ec 100644 --- a/lib/demos/material/tabs_demo.dart +++ b/lib/demos/material/tabs_demo.dart @@ -31,9 +31,56 @@ class TabsDemo extends StatelessWidget { // BEGIN tabsScrollableDemo -class _TabsScrollableDemo extends StatelessWidget { +class _TabsScrollableDemo extends StatefulWidget { + @override + __TabsScrollableDemoState createState() => __TabsScrollableDemoState(); +} + +class __TabsScrollableDemoState extends State<_TabsScrollableDemo> + with SingleTickerProviderStateMixin, RestorationMixin { + TabController _tabController; + + final RestorableInt tabIndex = RestorableInt(0); + + @override + String get restorationId => 'tab_scrollable_demo'; + + @override + void restoreState(RestorationBucket oldBucket, bool initialRestore) { + registerForRestoration(tabIndex, 'tab_index'); + } + + @override + void initState() { + _tabController = TabController( + initialIndex: 0, + length: 12, + vsync: this, + ); + _tabController.addListener(() { + // When the tab controller's value is updated, make sure to update the + // tab index value, which is state restorable. + setState(() { + tabIndex.value = _tabController.index; + }); + }); + super.initState(); + } + + @override + void dispose() { + _tabController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { + // Ensures that the tab controller's index is updated with the + // state restorable tab index value. + if (_tabController.index != tabIndex.value) { + _tabController.index = tabIndex.value; + } + final tabs = [ GalleryLocalizations.of(context).colorsRed, GalleryLocalizations.of(context).colorsOrange, @@ -49,28 +96,27 @@ class _TabsScrollableDemo extends StatelessWidget { GalleryLocalizations.of(context).colorsPurple, ]; - return DefaultTabController( - length: tabs.length, - child: Scaffold( - appBar: AppBar( - automaticallyImplyLeading: false, - title: Text(GalleryLocalizations.of(context).demoTabsScrollingTitle), - bottom: TabBar( - isScrollable: true, - tabs: [ - for (final tab in tabs) Tab(text: tab), - ], - ), - ), - body: TabBarView( - children: [ - for (final tab in tabs) - Center( - child: Text(tab), - ), + return Scaffold( + appBar: AppBar( + automaticallyImplyLeading: false, + title: Text(GalleryLocalizations.of(context).demoTabsScrollingTitle), + bottom: TabBar( + controller: _tabController, + isScrollable: true, + tabs: [ + for (final tab in tabs) Tab(text: tab), ], ), ), + body: TabBarView( + controller: _tabController, + children: [ + for (final tab in tabs) + Center( + child: Text(tab), + ), + ], + ), ); } } @@ -79,38 +125,85 @@ class _TabsScrollableDemo extends StatelessWidget { // BEGIN tabsNonScrollableDemo -class _TabsNonScrollableDemo extends StatelessWidget { +class _TabsNonScrollableDemo extends StatefulWidget { + @override + __TabsNonScrollableDemoState createState() => __TabsNonScrollableDemoState(); +} + +class __TabsNonScrollableDemoState extends State<_TabsNonScrollableDemo> + with SingleTickerProviderStateMixin, RestorationMixin { + TabController _tabController; + + final RestorableInt tabIndex = RestorableInt(0); + + @override + String get restorationId => 'tab_non_scrollable_demo'; + + @override + void restoreState(RestorationBucket oldBucket, bool initialRestore) { + registerForRestoration(tabIndex, 'tab_index'); + } + + @override + void initState() { + _tabController = TabController( + initialIndex: 0, + length: 3, + vsync: this, + ); + _tabController.addListener(() { + // When the tab controller's value is updated, make sure to update the + // tab index value, which is state restorable. + setState(() { + tabIndex.value = _tabController.index; + }); + }); + super.initState(); + } + + @override + void dispose() { + _tabController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { + // Ensures that the tab controller's index is updated with the + // state restorable tab index value. + if (_tabController.index != tabIndex.value) { + _tabController.index = tabIndex.value; + } + final tabs = [ GalleryLocalizations.of(context).colorsRed, GalleryLocalizations.of(context).colorsOrange, GalleryLocalizations.of(context).colorsGreen, ]; - return DefaultTabController( - length: tabs.length, - child: Scaffold( - appBar: AppBar( - automaticallyImplyLeading: false, - title: - Text(GalleryLocalizations.of(context).demoTabsNonScrollingTitle), - bottom: TabBar( - isScrollable: false, - tabs: [ - for (final tab in tabs) Tab(text: tab), - ], - ), + return Scaffold( + appBar: AppBar( + automaticallyImplyLeading: false, + title: Text( + GalleryLocalizations.of(context).demoTabsNonScrollingTitle, ), - body: TabBarView( - children: [ - for (final tab in tabs) - Center( - child: Text(tab), - ), + bottom: TabBar( + controller: _tabController, + isScrollable: false, + tabs: [ + for (final tab in tabs) Tab(text: tab), ], ), ), + body: TabBarView( + controller: _tabController, + children: [ + for (final tab in tabs) + Center( + child: Text(tab), + ), + ], + ), ); } } diff --git a/lib/demos/material/text_field_demo.dart b/lib/demos/material/text_field_demo.dart index a5c454a928..127de17f9d 100644 --- a/lib/demos/material/text_field_demo.dart +++ b/lib/demos/material/text_field_demo.dart @@ -16,6 +16,8 @@ class TextFieldDemo extends StatelessWidget { @override Widget build(BuildContext context) { + // TODO(shihaohong): Implement state restoration for TextFormField + // on the framework. return Scaffold( appBar: AppBar( automaticallyImplyLeading: false,