diff --git a/golden_test/demo_test.dart b/golden_test/demo_test.dart index 3d7169a874..5ef0a626ff 100644 --- a/golden_test/demo_test.dart +++ b/golden_test/demo_test.dart @@ -18,6 +18,7 @@ void main() { group('mobile', () { testWidgets('demo page matches golden screenshot', (tester) async { await setUpBinding(tester); + await tester.runAsync(pumpDeferredLibraries); await pumpWidgetWithImages( tester, const GalleryApp(initialRoute: demoBannerRoute), @@ -33,6 +34,7 @@ void main() { testWidgets('dark demo page matches golden screenshot', (tester) async { await setUpBinding(tester, brightness: Brightness.dark); + await tester.runAsync(pumpDeferredLibraries); await pumpWidgetWithImages( tester, const GalleryApp(initialRoute: demoBannerRoute), @@ -50,6 +52,7 @@ void main() { group('desktop', () { testWidgets('demo page matches golden screenshot', (tester) async { await setUpBinding(tester, size: desktopSize); + await tester.runAsync(pumpDeferredLibraries); await pumpWidgetWithImages( tester, const GalleryApp(initialRoute: demoBannerRoute), @@ -69,6 +72,7 @@ void main() { size: desktopSize, brightness: Brightness.dark, ); + await tester.runAsync(pumpDeferredLibraries); await pumpWidgetWithImages( tester, const GalleryApp(initialRoute: demoBannerRoute), diff --git a/lib/codeviewer/code_segments.dart b/lib/codeviewer/code_segments.dart index af027fc383..c9cd674131 100644 --- a/lib/codeviewer/code_segments.dart +++ b/lib/codeviewer/code_segments.dart @@ -2149,20 +2149,16 @@ class CodeSegments { TextSpan( style: codeStyle.stringStyle, text: - '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), - TextSpan(style: codeStyle.keywordStyle, text: 'enum'), - TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.classStyle, text: 'BottomNavigationDemoType'), - TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.punctuationStyle, text: '{'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a withLabels'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), - TextSpan(style: codeStyle.baseStyle, text: '\u000a withoutLabels'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: '\u000a'), - TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -3080,6 +3076,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -3376,6 +3380,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -3773,6 +3785,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -3934,6 +3954,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -4099,6 +4127,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -4260,6 +4296,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -4421,6 +4465,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -7076,6 +7128,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -7188,6 +7248,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -7566,6 +7634,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -7985,6 +8061,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -9705,24 +9789,13 @@ class CodeSegments { style: codeStyle.stringStyle, text: '\u0027package:gallery/data/gallery_options.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), - TextSpan(style: codeStyle.keywordStyle, text: 'enum'), - TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.classStyle, text: 'AlertDemoType'), - TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.punctuationStyle, text: '{'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a alert'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), - TextSpan(style: codeStyle.baseStyle, text: '\u000a alertTitle'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), - TextSpan(style: codeStyle.baseStyle, text: '\u000a alertButtons'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), - TextSpan(style: codeStyle.baseStyle, text: '\u000a alertButtonsOnly'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), - TextSpan(style: codeStyle.baseStyle, text: '\u000a actionSheet'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: '\u000a'), - TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: '\u0027package:gallery/demos/cupertino/demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -16279,6 +16352,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.classStyle, text: 'Path'), TextSpan(style: codeStyle.baseStyle, text: ' _downTriangle'), @@ -21512,24 +21593,16 @@ class CodeSegments { TextSpan( style: codeStyle.stringStyle, text: - '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), - TextSpan(style: codeStyle.keywordStyle, text: 'enum'), - TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.classStyle, text: 'DialogDemoType'), - TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.punctuationStyle, text: '{'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a alert'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), - TextSpan(style: codeStyle.baseStyle, text: '\u000a alertTitle'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), - TextSpan(style: codeStyle.baseStyle, text: '\u000a simple'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), - TextSpan(style: codeStyle.baseStyle, text: '\u000a fullscreen'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: '\u000a'), - TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -23031,6 +23104,14 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: '\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'import'), TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan( style: codeStyle.stringStyle, text: @@ -24954,20 +25035,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), - TextSpan(style: codeStyle.keywordStyle, text: 'enum'), - TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.classStyle, text: 'GridListDemoType'), - TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.punctuationStyle, text: '{'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a imageOnly'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), - TextSpan(style: codeStyle.baseStyle, text: '\u000a header'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), - TextSpan(style: codeStyle.baseStyle, text: '\u000a footer'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: '\u000a'), - TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -26065,18 +26140,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), - TextSpan(style: codeStyle.keywordStyle, text: 'enum'), - TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.classStyle, text: 'ListDemoType'), - TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.punctuationStyle, text: '{'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a oneLine'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), - TextSpan(style: codeStyle.baseStyle, text: '\u000a twoLine'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: '\u000a'), - TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -26328,6 +26399,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan( style: codeStyle.commentStyle, @@ -27237,6 +27316,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan( style: codeStyle.commentStyle, @@ -27521,6 +27608,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan( style: codeStyle.commentStyle, @@ -27915,6 +28010,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan( style: codeStyle.commentStyle, @@ -32109,22 +32212,16 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan( style: codeStyle.stringStyle, - text: '\u0027package:intl/intl.dart\u0027'), + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), - TextSpan(style: codeStyle.keywordStyle, text: 'enum'), - TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.classStyle, text: 'PickerDemoType'), - TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.punctuationStyle, text: '{'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a date'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), - TextSpan(style: codeStyle.baseStyle, text: '\u000a time'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), - TextSpan(style: codeStyle.baseStyle, text: '\u000a range'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: '\u000a'), - TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: '\u0027package:intl/intl.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -32894,18 +32991,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), - TextSpan(style: codeStyle.keywordStyle, text: 'enum'), - TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.classStyle, text: 'ProgressIndicatorDemoType'), - TextSpan(style: codeStyle.baseStyle, text: ' '), - TextSpan(style: codeStyle.punctuationStyle, text: '{'), - TextSpan(style: codeStyle.baseStyle, text: '\u000a circular'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), - TextSpan(style: codeStyle.baseStyle, text: '\u000a linear'), - TextSpan(style: codeStyle.punctuationStyle, text: ','), TextSpan(style: codeStyle.baseStyle, text: '\u000a'), - TextSpan(style: codeStyle.punctuationStyle, text: '}'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -33465,6 +33558,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -34000,6 +34101,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -34334,6 +34443,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -34580,6 +34697,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -38306,6 +38431,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -39110,6 +39243,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -39506,6 +39647,14 @@ class CodeSegments { text: '\u0027package:flutter_gen/gen_l10n/gallery_localizations.dart\u0027'), TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'class'), TextSpan(style: codeStyle.baseStyle, text: ' '), @@ -46065,6 +46214,14 @@ class CodeSegments { TextSpan(style: codeStyle.baseStyle, text: '\u000a'), TextSpan(style: codeStyle.keywordStyle, text: 'import'), TextSpan(style: codeStyle.baseStyle, text: ' '), + TextSpan( + style: codeStyle.stringStyle, + text: + '\u0027package:gallery/demos/material/material_demo_types.dart\u0027'), + TextSpan(style: codeStyle.punctuationStyle, text: ';'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a'), + TextSpan(style: codeStyle.keywordStyle, text: 'import'), + TextSpan(style: codeStyle.baseStyle, text: ' '), TextSpan( style: codeStyle.stringStyle, text: diff --git a/lib/data/demos.dart b/lib/data/demos.dart index e974a39bcc..1f3c7d8fde 100644 --- a/lib/data/demos.dart +++ b/lib/data/demos.dart @@ -9,51 +9,27 @@ import 'package:flutter/material.dart'; import 'package:gallery/codeviewer/code_displayer.dart'; import 'package:gallery/codeviewer/code_segments.dart'; import 'package:gallery/data/icons.dart'; -import 'package:gallery/demos/cupertino/cupertino_activity_indicator_demo.dart'; -import 'package:gallery/demos/cupertino/cupertino_alert_demo.dart'; -import 'package:gallery/demos/cupertino/cupertino_button_demo.dart'; -import 'package:gallery/demos/cupertino/cupertino_context_menu_demo.dart'; -import 'package:gallery/demos/cupertino/cupertino_navigation_bar_demo.dart'; -import 'package:gallery/demos/cupertino/cupertino_picker_demo.dart'; -import 'package:gallery/demos/cupertino/cupertino_refresh_demo.dart'; -import 'package:gallery/demos/cupertino/cupertino_segmented_control_demo.dart'; -import 'package:gallery/demos/cupertino/cupertino_slider_demo.dart'; -import 'package:gallery/demos/cupertino/cupertino_switch_demo.dart'; -import 'package:gallery/demos/cupertino/cupertino_tab_bar_demo.dart'; -import 'package:gallery/demos/cupertino/cupertino_text_field_demo.dart'; -import 'package:gallery/demos/material/banner_demo.dart'; -import 'package:gallery/demos/material/bottom_app_bar_demo.dart'; -import 'package:gallery/demos/material/bottom_navigation_demo.dart'; -import 'package:gallery/demos/material/bottom_sheet_demo.dart'; -import 'package:gallery/demos/material/button_demo.dart'; -import 'package:gallery/demos/material/cards_demo.dart'; -import 'package:gallery/demos/material/chip_demo.dart'; -import 'package:gallery/demos/material/data_table_demo.dart'; -import 'package:gallery/demos/material/dialog_demo.dart'; -import 'package:gallery/demos/material/divider_demo.dart'; -import 'package:gallery/demos/material/grid_list_demo.dart'; -import 'package:gallery/demos/material/list_demo.dart'; -import 'package:gallery/demos/material/menu_demo.dart'; -import 'package:gallery/demos/material/navigation_drawer.dart'; -import 'package:gallery/demos/material/navigation_rail_demo.dart'; -import 'package:gallery/demos/material/picker_demo.dart'; -import 'package:gallery/demos/material/progress_indicator_demo.dart'; -import 'package:gallery/demos/material/selection_controls_demo.dart'; -import 'package:gallery/demos/material/sliders_demo.dart'; -import 'package:gallery/demos/material/snackbar_demo.dart'; -import 'package:gallery/demos/material/tabs_demo.dart'; -import 'package:gallery/demos/material/text_field_demo.dart'; -import 'package:gallery/demos/material/tooltip_demo.dart'; -import 'package:gallery/demos/material/app_bar_demo.dart'; -import 'package:gallery/demos/reference/motion_demo_container_transition.dart'; + +import 'package:gallery/deferred_widget.dart'; +import 'package:gallery/demos/cupertino/cupertino_demos.dart' + deferred as cupertino_demos; +import 'package:gallery/demos/cupertino/demo_types.dart'; +import 'package:gallery/demos/material/material_demos.dart' + deferred as material_demos; +import 'package:gallery/demos/material/material_demo_types.dart'; +import 'package:gallery/demos/reference/motion_demo_container_transition.dart' + deferred as motion_demo_container; import 'package:gallery/demos/reference/motion_demo_fade_through_transition.dart'; import 'package:gallery/demos/reference/motion_demo_fade_scale_transition.dart'; import 'package:gallery/demos/reference/motion_demo_shared_x_axis_transition.dart'; import 'package:gallery/demos/reference/motion_demo_shared_y_axis_transition.dart'; import 'package:gallery/demos/reference/motion_demo_shared_z_axis_transition.dart'; -import 'package:gallery/demos/reference/colors_demo.dart'; -import 'package:gallery/demos/reference/transformations_demo.dart'; -import 'package:gallery/demos/reference/typography_demo.dart'; +import 'package:gallery/demos/reference/colors_demo.dart' + deferred as colors_demo; +import 'package:gallery/demos/reference/transformations_demo.dart' + deferred as transformations_demo; +import 'package:gallery/demos/reference/typography_demo.dart' + deferred as typography; import 'package:flutter_gen/gen_l10n/gallery_localizations.dart'; import 'package:flutter_gen/gen_l10n/gallery_localizations_en.dart' show GalleryLocalizationsEn; @@ -184,6 +160,7 @@ Map studies(GalleryLocalizations localizations) { } List materialDemos(GalleryLocalizations localizations) { + LibraryLoader materialDemosLibrary = material_demos.loadLibrary; return [ GalleryDemo( title: localizations.demoAppBarTitle, @@ -195,7 +172,10 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoAppBarTitle, description: localizations.demoAppBarDescription, documentationUrl: '$_docsBaseUrl/material/AppBar-class.html', - buildRoute: (_) => const AppBarDemo(), + buildRoute: (_) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.AppBarDemo()), code: CodeSegments.appbarDemo, ), ], @@ -211,7 +191,10 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoBannerTitle, description: localizations.demoBannerDescription, documentationUrl: '$_docsBaseUrl/material/MaterialBanner-class.html', - buildRoute: (_) => const BannerDemo(), + buildRoute: (_) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.BannerDemo()), code: CodeSegments.bannerDemo, ), ], @@ -227,7 +210,10 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoBottomAppBarTitle, description: localizations.demoBottomAppBarDescription, documentationUrl: '$_docsBaseUrl/material/BottomAppBar-class.html', - buildRoute: (_) => const BottomAppBarDemo(), + buildRoute: (_) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.BottomAppBarDemo()), code: CodeSegments.bottomAppBarDemo, ), ], @@ -244,10 +230,13 @@ List materialDemos(GalleryLocalizations localizations) { description: localizations.demoBottomNavigationDescription, documentationUrl: '$_docsBaseUrl/material/BottomNavigationBar-class.html', - buildRoute: (_) => const BottomNavigationDemo( - type: BottomNavigationDemoType.withLabels, - restorationId: 'bottom_navigation_labels_demo', - ), + buildRoute: (_) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.BottomNavigationDemo( + type: BottomNavigationDemoType.withLabels, + restorationId: 'bottom_navigation_labels_demo', + )), code: CodeSegments.bottomNavigationDemo, ), GalleryDemoConfiguration( @@ -255,10 +244,13 @@ List materialDemos(GalleryLocalizations localizations) { description: localizations.demoBottomNavigationDescription, documentationUrl: '$_docsBaseUrl/material/BottomNavigationBar-class.html', - buildRoute: (_) => const BottomNavigationDemo( - type: BottomNavigationDemoType.withoutLabels, - restorationId: 'bottom_navigation_without_labels_demo', - ), + buildRoute: (_) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.BottomNavigationDemo( + type: BottomNavigationDemoType.withoutLabels, + restorationId: 'bottom_navigation_without_labels_demo', + )), code: CodeSegments.bottomNavigationDemo, ), ], @@ -274,18 +266,24 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoBottomSheetPersistentTitle, description: localizations.demoBottomSheetPersistentDescription, documentationUrl: '$_docsBaseUrl/material/BottomSheet-class.html', - buildRoute: (_) => const BottomSheetDemo( - type: BottomSheetDemoType.persistent, - ), + buildRoute: (_) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.BottomSheetDemo( + type: BottomSheetDemoType.persistent, + )), code: CodeSegments.bottomSheetDemoPersistent, ), GalleryDemoConfiguration( title: localizations.demoBottomSheetModalTitle, description: localizations.demoBottomSheetModalDescription, documentationUrl: '$_docsBaseUrl/material/BottomSheet-class.html', - buildRoute: (_) => const BottomSheetDemo( - type: BottomSheetDemoType.modal, - ), + buildRoute: (_) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.BottomSheetDemo( + type: BottomSheetDemoType.modal, + )), code: CodeSegments.bottomSheetDemoModal, ), ], @@ -301,28 +299,40 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoTextButtonTitle, description: localizations.demoTextButtonDescription, documentationUrl: '$_docsBaseUrl/material/TextButton-class.html', - buildRoute: (_) => const ButtonDemo(type: ButtonDemoType.text), + buildRoute: (_) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.ButtonDemo(type: ButtonDemoType.text)), code: CodeSegments.buttonDemoText, ), GalleryDemoConfiguration( title: localizations.demoElevatedButtonTitle, description: localizations.demoElevatedButtonDescription, documentationUrl: '$_docsBaseUrl/material/ElevatedButton-class.html', - buildRoute: (_) => const ButtonDemo(type: ButtonDemoType.elevated), + buildRoute: (_) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.ButtonDemo(type: ButtonDemoType.elevated)), code: CodeSegments.buttonDemoElevated, ), GalleryDemoConfiguration( title: localizations.demoOutlinedButtonTitle, description: localizations.demoOutlinedButtonDescription, documentationUrl: '$_docsBaseUrl/material/OutlinedButton-class.html', - buildRoute: (_) => const ButtonDemo(type: ButtonDemoType.outlined), + buildRoute: (_) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.ButtonDemo(type: ButtonDemoType.outlined)), code: CodeSegments.buttonDemoOutlined, ), GalleryDemoConfiguration( title: localizations.demoToggleButtonTitle, description: localizations.demoToggleButtonDescription, documentationUrl: '$_docsBaseUrl/material/ToggleButtons-class.html', - buildRoute: (_) => const ButtonDemo(type: ButtonDemoType.toggle), + buildRoute: (_) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.ButtonDemo(type: ButtonDemoType.toggle)), code: CodeSegments.buttonDemoToggle, ), GalleryDemoConfiguration( @@ -330,7 +340,10 @@ List materialDemos(GalleryLocalizations localizations) { description: localizations.demoFloatingButtonDescription, documentationUrl: '$_docsBaseUrl/material/FloatingActionButton-class.html', - buildRoute: (_) => const ButtonDemo(type: ButtonDemoType.floating), + buildRoute: (_) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.ButtonDemo(type: ButtonDemoType.floating)), code: CodeSegments.buttonDemoFloating, ), ], @@ -346,7 +359,10 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoCardTitle, description: localizations.demoCardDescription, documentationUrl: '$_docsBaseUrl/material/Card-class.html', - buildRoute: (context) => const CardsDemo(), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.CardsDemo()), code: CodeSegments.cardsDemo, ), ], @@ -362,28 +378,40 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoActionChipTitle, description: localizations.demoActionChipDescription, documentationUrl: '$_docsBaseUrl/material/ActionChip-class.html', - buildRoute: (_) => const ChipDemo(type: ChipDemoType.action), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.ChipDemo(type: ChipDemoType.action)), code: CodeSegments.chipDemoAction, ), GalleryDemoConfiguration( title: localizations.demoChoiceChipTitle, description: localizations.demoChoiceChipDescription, documentationUrl: '$_docsBaseUrl/material/ChoiceChip-class.html', - buildRoute: (_) => const ChipDemo(type: ChipDemoType.choice), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.ChipDemo(type: ChipDemoType.choice)), code: CodeSegments.chipDemoChoice, ), GalleryDemoConfiguration( title: localizations.demoFilterChipTitle, description: localizations.demoFilterChipDescription, documentationUrl: '$_docsBaseUrl/material/FilterChip-class.html', - buildRoute: (_) => const ChipDemo(type: ChipDemoType.filter), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.ChipDemo(type: ChipDemoType.filter)), code: CodeSegments.chipDemoFilter, ), GalleryDemoConfiguration( title: localizations.demoInputChipTitle, description: localizations.demoInputChipDescription, documentationUrl: '$_docsBaseUrl/material/InputChip-class.html', - buildRoute: (_) => const ChipDemo(type: ChipDemoType.input), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.ChipDemo(type: ChipDemoType.input)), code: CodeSegments.chipDemoInput, ), ], @@ -399,7 +427,10 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoDataTableTitle, description: localizations.demoDataTableDescription, documentationUrl: '$_docsBaseUrl/material/DataTable-class.html', - buildRoute: (_) => const DataTableDemo(), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.DataTableDemo()), code: CodeSegments.dataTableDemo, ), ], @@ -415,21 +446,26 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoAlertDialogTitle, description: localizations.demoAlertDialogDescription, documentationUrl: '$_docsBaseUrl/material/AlertDialog-class.html', - buildRoute: (_) => DialogDemo(type: DialogDemoType.alert), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.DialogDemo(type: DialogDemoType.alert)), code: CodeSegments.dialogDemo, ), GalleryDemoConfiguration( title: localizations.demoAlertTitleDialogTitle, description: localizations.demoAlertDialogDescription, documentationUrl: '$_docsBaseUrl/material/AlertDialog-class.html', - buildRoute: (_) => DialogDemo(type: DialogDemoType.alertTitle), + buildRoute: (context) => DeferredWidget(materialDemosLibrary, + () => material_demos.DialogDemo(type: DialogDemoType.alertTitle)), code: CodeSegments.dialogDemo, ), GalleryDemoConfiguration( title: localizations.demoSimpleDialogTitle, description: localizations.demoSimpleDialogDescription, documentationUrl: '$_docsBaseUrl/material/SimpleDialog-class.html', - buildRoute: (_) => DialogDemo(type: DialogDemoType.simple), + buildRoute: (context) => DeferredWidget(materialDemosLibrary, + () => material_demos.DialogDemo(type: DialogDemoType.simple)), code: CodeSegments.dialogDemo, ), GalleryDemoConfiguration( @@ -437,7 +473,8 @@ List materialDemos(GalleryLocalizations localizations) { description: localizations.demoFullscreenDialogDescription, documentationUrl: '$_docsBaseUrl/widgets/PageRoute/fullscreenDialog.html', - buildRoute: (_) => DialogDemo(type: DialogDemoType.fullscreen), + buildRoute: (context) => DeferredWidget(materialDemosLibrary, + () => material_demos.DialogDemo(type: DialogDemoType.fullscreen)), code: CodeSegments.dialogDemo, ), ], @@ -453,15 +490,21 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoDividerTitle, description: localizations.demoDividerDescription, documentationUrl: '$_docsBaseUrl/material/Divider-class.html', - buildRoute: (_) => - const DividerDemo(type: DividerDemoType.horizontal), + buildRoute: (_) => DeferredWidget( + materialDemosLibrary, + () => + // ignore: prefer_const_constructors + material_demos.DividerDemo(type: DividerDemoType.horizontal)), code: CodeSegments.dividerDemo, ), GalleryDemoConfiguration( title: localizations.demoVerticalDividerTitle, description: localizations.demoDividerDescription, documentationUrl: '$_docsBaseUrl/material/VerticalDivider-class.html', - buildRoute: (_) => const DividerDemo(type: DividerDemoType.vertical), + buildRoute: (_) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.DividerDemo(type: DividerDemoType.vertical)), code: CodeSegments.verticalDividerDemo, ), ], @@ -477,24 +520,31 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoGridListsImageOnlyTitle, description: localizations.demoGridListsDescription, documentationUrl: '$_docsBaseUrl/widgets/GridView-class.html', - buildRoute: (context) => - const GridListDemo(type: GridListDemoType.imageOnly), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.GridListDemo( + type: GridListDemoType.imageOnly)), code: CodeSegments.gridListsDemo, ), GalleryDemoConfiguration( title: localizations.demoGridListsHeaderTitle, description: localizations.demoGridListsDescription, documentationUrl: '$_docsBaseUrl/widgets/GridView-class.html', - buildRoute: (context) => - const GridListDemo(type: GridListDemoType.header), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.GridListDemo(type: GridListDemoType.header)), code: CodeSegments.gridListsDemo, ), GalleryDemoConfiguration( title: localizations.demoGridListsFooterTitle, description: localizations.demoGridListsDescription, documentationUrl: '$_docsBaseUrl/widgets/GridView-class.html', - buildRoute: (context) => - const GridListDemo(type: GridListDemoType.footer), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.GridListDemo(type: GridListDemoType.footer)), code: CodeSegments.gridListsDemo, ), ], @@ -510,14 +560,20 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoOneLineListsTitle, description: localizations.demoListsDescription, documentationUrl: '$_docsBaseUrl/material/ListTile-class.html', - buildRoute: (context) => const ListDemo(type: ListDemoType.oneLine), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.ListDemo(type: ListDemoType.oneLine)), code: CodeSegments.listDemo, ), GalleryDemoConfiguration( title: localizations.demoTwoLineListsTitle, description: localizations.demoListsDescription, documentationUrl: '$_docsBaseUrl/material/ListTile-class.html', - buildRoute: (context) => const ListDemo(type: ListDemoType.twoLine), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.ListDemo(type: ListDemoType.twoLine)), code: CodeSegments.listDemo, ), ], @@ -533,8 +589,10 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoContextMenuTitle, description: localizations.demoMenuDescription, documentationUrl: '$_docsBaseUrl/material/PopupMenuItem-class.html', - buildRoute: (context) => const MenuDemo( - type: MenuDemoType.contextMenu, + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.MenuDemo(type: MenuDemoType.contextMenu), ), code: CodeSegments.menuDemoContext, ), @@ -542,8 +600,10 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoSectionedMenuTitle, description: localizations.demoMenuDescription, documentationUrl: '$_docsBaseUrl/material/PopupMenuItem-class.html', - buildRoute: (context) => const MenuDemo( - type: MenuDemoType.sectionedMenu, + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.MenuDemo(type: MenuDemoType.sectionedMenu), ), code: CodeSegments.menuDemoSectioned, ), @@ -552,8 +612,10 @@ List materialDemos(GalleryLocalizations localizations) { description: localizations.demoMenuDescription, documentationUrl: '$_docsBaseUrl/material/CheckedPopupMenuItem-class.html', - buildRoute: (context) => const MenuDemo( - type: MenuDemoType.checklistMenu, + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.MenuDemo(type: MenuDemoType.checklistMenu), ), code: CodeSegments.menuDemoChecklist, ), @@ -561,8 +623,10 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoSimpleMenuTitle, description: localizations.demoMenuDescription, documentationUrl: '$_docsBaseUrl/material/PopupMenuItem-class.html', - buildRoute: (context) => const MenuDemo( - type: MenuDemoType.simpleMenu, + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.MenuDemo(type: MenuDemoType.simpleMenu), ), code: CodeSegments.menuDemoSimple, ), @@ -579,7 +643,11 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoNavigationDrawerTitle, description: localizations.demoNavigationDrawerDescription, documentationUrl: '$_docsBaseUrl/material/Drawer-class.html', - buildRoute: (_) => const NavDrawerDemo(), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.NavDrawerDemo(), + ), code: CodeSegments.navDrawerDemo, ), ], @@ -595,7 +663,11 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoNavigationRailTitle, description: localizations.demoNavigationRailDescription, documentationUrl: '$_docsBaseUrl/material/NavigationRail-class.html', - buildRoute: (_) => const NavRailDemo(), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.NavRailDemo(), + ), code: CodeSegments.navRailDemo, ), ], @@ -611,21 +683,33 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoDatePickerTitle, description: localizations.demoDatePickerDescription, documentationUrl: '$_docsBaseUrl/material/showDatePicker.html', - buildRoute: (context) => const PickerDemo(type: PickerDemoType.date), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.PickerDemo(type: PickerDemoType.date), + ), code: CodeSegments.pickerDemo, ), GalleryDemoConfiguration( title: localizations.demoTimePickerTitle, description: localizations.demoTimePickerDescription, documentationUrl: '$_docsBaseUrl/material/showTimePicker.html', - buildRoute: (context) => const PickerDemo(type: PickerDemoType.time), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.PickerDemo(type: PickerDemoType.time), + ), code: CodeSegments.pickerDemo, ), GalleryDemoConfiguration( title: localizations.demoDateRangePickerTitle, description: localizations.demoDateRangePickerDescription, documentationUrl: '$_docsBaseUrl/material/showDateRangePicker.html', - buildRoute: (context) => const PickerDemo(type: PickerDemoType.range), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.PickerDemo(type: PickerDemoType.range), + ), code: CodeSegments.pickerDemo, ), ], @@ -642,8 +726,12 @@ List materialDemos(GalleryLocalizations localizations) { description: localizations.demoCircularProgressIndicatorDescription, documentationUrl: '$_docsBaseUrl/material/CircularProgressIndicator-class.html', - buildRoute: (context) => const ProgressIndicatorDemo( - type: ProgressIndicatorDemoType.circular, + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.ProgressIndicatorDemo( + type: ProgressIndicatorDemoType.circular, + ), ), code: CodeSegments.progressIndicatorsDemo, ), @@ -652,8 +740,12 @@ List materialDemos(GalleryLocalizations localizations) { description: localizations.demoLinearProgressIndicatorDescription, documentationUrl: '$_docsBaseUrl/material/LinearProgressIndicator-class.html', - buildRoute: (context) => const ProgressIndicatorDemo( - type: ProgressIndicatorDemoType.linear, + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.ProgressIndicatorDemo( + type: ProgressIndicatorDemoType.linear, + ), ), code: CodeSegments.progressIndicatorsDemo, ), @@ -670,8 +762,12 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoSelectionControlsCheckboxTitle, description: localizations.demoSelectionControlsCheckboxDescription, documentationUrl: '$_docsBaseUrl/material/Checkbox-class.html', - buildRoute: (context) => const SelectionControlsDemo( - type: SelectionControlsDemoType.checkbox, + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.SelectionControlsDemo( + type: SelectionControlsDemoType.checkbox, + ), ), code: CodeSegments.selectionControlsDemoCheckbox, ), @@ -679,8 +775,12 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoSelectionControlsRadioTitle, description: localizations.demoSelectionControlsRadioDescription, documentationUrl: '$_docsBaseUrl/material/Radio-class.html', - buildRoute: (context) => const SelectionControlsDemo( - type: SelectionControlsDemoType.radio, + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.SelectionControlsDemo( + type: SelectionControlsDemoType.radio, + ), ), code: CodeSegments.selectionControlsDemoRadio, ), @@ -688,8 +788,12 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoSelectionControlsSwitchTitle, description: localizations.demoSelectionControlsSwitchDescription, documentationUrl: '$_docsBaseUrl/material/Switch-class.html', - buildRoute: (context) => const SelectionControlsDemo( - type: SelectionControlsDemoType.switches, + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.SelectionControlsDemo( + type: SelectionControlsDemoType.switches, + ), ), code: CodeSegments.selectionControlsDemoSwitches, ), @@ -706,24 +810,35 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoSlidersTitle, description: localizations.demoSlidersDescription, documentationUrl: '$_docsBaseUrl/material/Slider-class.html', - buildRoute: (context) => - const SlidersDemo(type: SlidersDemoType.sliders), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.SlidersDemo(type: SlidersDemoType.sliders), + ), code: CodeSegments.slidersDemo, ), GalleryDemoConfiguration( title: localizations.demoRangeSlidersTitle, description: localizations.demoRangeSlidersDescription, documentationUrl: '$_docsBaseUrl/material/RangeSlider-class.html', - buildRoute: (context) => - const SlidersDemo(type: SlidersDemoType.rangeSliders), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + () => + // ignore: prefer_const_constructors + material_demos.SlidersDemo(type: SlidersDemoType.rangeSliders), + ), code: CodeSegments.rangeSlidersDemo, ), GalleryDemoConfiguration( title: localizations.demoCustomSlidersTitle, description: localizations.demoCustomSlidersDescription, documentationUrl: '$_docsBaseUrl/material/SliderTheme-class.html', - buildRoute: (context) => - const SlidersDemo(type: SlidersDemoType.customSliders), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + () => + // ignore: prefer_const_constructors + material_demos.SlidersDemo(type: SlidersDemoType.customSliders), + ), code: CodeSegments.customSlidersDemo, ), ], @@ -739,7 +854,11 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoSnackbarsTitle, description: localizations.demoSnackbarsDescription, documentationUrl: '$_docsBaseUrl/material/SnackBar-class.html', - buildRoute: (context) => const SnackbarsDemo(), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.SnackbarsDemo(), + ), code: CodeSegments.snackbarsDemo, ), ], @@ -755,16 +874,22 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoTabsScrollingTitle, description: localizations.demoTabsDescription, documentationUrl: '$_docsBaseUrl/material/TabBar-class.html', - buildRoute: (context) => - const TabsDemo(type: TabsDemoType.scrollable), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.TabsDemo(type: TabsDemoType.scrollable), + ), code: CodeSegments.tabsScrollableDemo, ), GalleryDemoConfiguration( title: localizations.demoTabsNonScrollingTitle, description: localizations.demoTabsDescription, documentationUrl: '$_docsBaseUrl/material/TabBar-class.html', - buildRoute: (context) => - const TabsDemo(type: TabsDemoType.nonScrollable), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.TabsDemo(type: TabsDemoType.nonScrollable), + ), code: CodeSegments.tabsNonScrollableDemo, ), ], @@ -780,7 +905,11 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoTextFieldTitle, description: localizations.demoTextFieldDescription, documentationUrl: '$_docsBaseUrl/material/TextField-class.html', - buildRoute: (_) => const TextFieldDemo(), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.TextFieldDemo(), + ), code: CodeSegments.textFieldDemo, ), ], @@ -796,7 +925,11 @@ List materialDemos(GalleryLocalizations localizations) { title: localizations.demoTooltipTitle, description: localizations.demoTooltipDescription, documentationUrl: '$_docsBaseUrl/material/Tooltip-class.html', - buildRoute: (_) => const TooltipDemo(), + buildRoute: (context) => DeferredWidget( + materialDemosLibrary, + // ignore: prefer_const_constructors + () => material_demos.TooltipDemo(), + ), code: CodeSegments.tooltipDemo, ), ], @@ -806,6 +939,7 @@ List materialDemos(GalleryLocalizations localizations) { } List cupertinoDemos(GalleryLocalizations localizations) { + LibraryLoader cupertinoLoader = cupertino_demos.loadLibrary; return [ GalleryDemo( title: localizations.demoCupertinoActivityIndicatorTitle, @@ -818,7 +952,10 @@ List cupertinoDemos(GalleryLocalizations localizations) { description: localizations.demoCupertinoActivityIndicatorDescription, documentationUrl: '$_docsBaseUrl/cupertino/CupertinoActivityIndicator-class.html', - buildRoute: (_) => const CupertinoProgressIndicatorDemo(), + buildRoute: (_) => DeferredWidget( + cupertinoLoader, + // ignore: prefer_const_constructors + () => cupertino_demos.CupertinoProgressIndicatorDemo()), code: CodeSegments.cupertinoActivityIndicatorDemo, ), ], @@ -835,8 +972,11 @@ List cupertinoDemos(GalleryLocalizations localizations) { description: localizations.demoCupertinoAlertDescription, documentationUrl: '$_docsBaseUrl/cupertino/CupertinoAlertDialog-class.html', - buildRoute: (_) => - const CupertinoAlertDemo(type: AlertDemoType.alert), + buildRoute: (_) => DeferredWidget( + cupertinoLoader, + // ignore: prefer_const_constructors + () => cupertino_demos.CupertinoAlertDemo( + type: AlertDemoType.alert)), code: CodeSegments.cupertinoAlertDemo, ), GalleryDemoConfiguration( @@ -844,8 +984,11 @@ List cupertinoDemos(GalleryLocalizations localizations) { description: localizations.demoCupertinoAlertDescription, documentationUrl: '$_docsBaseUrl/cupertino/CupertinoAlertDialog-class.html', - buildRoute: (_) => - const CupertinoAlertDemo(type: AlertDemoType.alertTitle), + buildRoute: (_) => DeferredWidget( + cupertinoLoader, + // ignore: prefer_const_constructors + () => cupertino_demos.CupertinoAlertDemo( + type: AlertDemoType.alertTitle)), code: CodeSegments.cupertinoAlertDemo, ), GalleryDemoConfiguration( @@ -853,8 +996,11 @@ List cupertinoDemos(GalleryLocalizations localizations) { description: localizations.demoCupertinoAlertDescription, documentationUrl: '$_docsBaseUrl/cupertino/CupertinoAlertDialog-class.html', - buildRoute: (_) => - const CupertinoAlertDemo(type: AlertDemoType.alertButtons), + buildRoute: (_) => DeferredWidget( + cupertinoLoader, + // ignore: prefer_const_constructors + () => cupertino_demos.CupertinoAlertDemo( + type: AlertDemoType.alertButtons)), code: CodeSegments.cupertinoAlertDemo, ), GalleryDemoConfiguration( @@ -862,8 +1008,11 @@ List cupertinoDemos(GalleryLocalizations localizations) { description: localizations.demoCupertinoAlertDescription, documentationUrl: '$_docsBaseUrl/cupertino/CupertinoAlertDialog-class.html', - buildRoute: (_) => - const CupertinoAlertDemo(type: AlertDemoType.alertButtonsOnly), + buildRoute: (_) => DeferredWidget( + cupertinoLoader, + // ignore: prefer_const_constructors + () => cupertino_demos.CupertinoAlertDemo( + type: AlertDemoType.alertButtonsOnly)), code: CodeSegments.cupertinoAlertDemo, ), GalleryDemoConfiguration( @@ -871,8 +1020,11 @@ List cupertinoDemos(GalleryLocalizations localizations) { description: localizations.demoCupertinoActionSheetDescription, documentationUrl: '$_docsBaseUrl/cupertino/CupertinoActionSheet-class.html', - buildRoute: (_) => - const CupertinoAlertDemo(type: AlertDemoType.actionSheet), + buildRoute: (_) => DeferredWidget( + cupertinoLoader, + // ignore: prefer_const_constructors + () => cupertino_demos.CupertinoAlertDemo( + type: AlertDemoType.actionSheet)), code: CodeSegments.cupertinoAlertDemo, ), ], @@ -889,7 +1041,10 @@ List cupertinoDemos(GalleryLocalizations localizations) { description: localizations.demoCupertinoButtonsDescription, documentationUrl: '$_docsBaseUrl/cupertino/CupertinoButton-class.html', - buildRoute: (_) => const CupertinoButtonDemo(), + buildRoute: (_) => DeferredWidget( + cupertinoLoader, + // ignore: prefer_const_constructors + () => cupertino_demos.CupertinoButtonDemo()), code: CodeSegments.cupertinoButtonDemo, ), ], @@ -906,7 +1061,10 @@ List cupertinoDemos(GalleryLocalizations localizations) { description: localizations.demoCupertinoContextMenuDescription, documentationUrl: '$_docsBaseUrl/cupertino/CupertinoContextMenu-class.html', - buildRoute: (_) => const CupertinoContextMenuDemo(), + buildRoute: (_) => DeferredWidget( + cupertinoLoader, + // ignore: prefer_const_constructors + () => cupertino_demos.CupertinoContextMenuDemo()), code: CodeSegments.cupertinoContextMenuDemo, ), ], @@ -923,7 +1081,10 @@ List cupertinoDemos(GalleryLocalizations localizations) { description: localizations.demoCupertinoNavigationBarDescription, documentationUrl: '$_docsBaseUrl/cupertino/CupertinoNavigationBar-class.html', - buildRoute: (_) => const CupertinoNavigationBarDemo(), + buildRoute: (_) => DeferredWidget( + cupertinoLoader, + // ignore: prefer_const_constructors + () => cupertino_demos.CupertinoNavigationBarDemo()), code: CodeSegments.cupertinoNavigationBarDemo, ), ], @@ -940,7 +1101,10 @@ List cupertinoDemos(GalleryLocalizations localizations) { description: localizations.demoCupertinoPickerDescription, documentationUrl: '$_docsBaseUrl/cupertino/CupertinoDatePicker-class.html', - buildRoute: (_) => const CupertinoPickerDemo(), + buildRoute: (_) => DeferredWidget( + cupertinoLoader, + // ignore: prefer_const_constructors + () => cupertino_demos.CupertinoPickerDemo()), code: CodeSegments.cupertinoPickersDemo, ), ], @@ -957,7 +1121,10 @@ List cupertinoDemos(GalleryLocalizations localizations) { description: localizations.demoCupertinoPullToRefreshDescription, documentationUrl: '$_docsBaseUrl/cupertino/CupertinoSliverRefreshControl-class.html', - buildRoute: (_) => const CupertinoRefreshControlDemo(), + buildRoute: (_) => DeferredWidget( + cupertinoLoader, + // ignore: prefer_const_constructors + () => cupertino_demos.CupertinoRefreshControlDemo()), code: CodeSegments.cupertinoRefreshDemo, ), ], @@ -974,7 +1141,10 @@ List cupertinoDemos(GalleryLocalizations localizations) { description: localizations.demoCupertinoSegmentedControlDescription, documentationUrl: '$_docsBaseUrl/cupertino/CupertinoSegmentedControl-class.html', - buildRoute: (_) => const CupertinoSegmentedControlDemo(), + buildRoute: (_) => DeferredWidget( + cupertinoLoader, + // ignore: prefer_const_constructors + () => cupertino_demos.CupertinoSegmentedControlDemo()), code: CodeSegments.cupertinoSegmentedControlDemo, ), ], @@ -991,7 +1161,10 @@ List cupertinoDemos(GalleryLocalizations localizations) { description: localizations.demoCupertinoSliderDescription, documentationUrl: '$_docsBaseUrl/cupertino/CupertinoSlider-class.html', - buildRoute: (_) => const CupertinoSliderDemo(), + buildRoute: (_) => DeferredWidget( + cupertinoLoader, + // ignore: prefer_const_constructors + () => cupertino_demos.CupertinoSliderDemo()), code: CodeSegments.cupertinoSliderDemo, ), ], @@ -1008,7 +1181,10 @@ List cupertinoDemos(GalleryLocalizations localizations) { description: localizations.demoCupertinoSwitchDescription, documentationUrl: '$_docsBaseUrl/cupertino/CupertinoSwitch-class.html', - buildRoute: (_) => const CupertinoSwitchDemo(), + buildRoute: (_) => DeferredWidget( + cupertinoLoader, + // ignore: prefer_const_constructors + () => cupertino_demos.CupertinoSwitchDemo()), code: CodeSegments.cupertinoSwitchDemo, ), ], @@ -1025,7 +1201,10 @@ List cupertinoDemos(GalleryLocalizations localizations) { description: localizations.demoCupertinoTabBarDescription, documentationUrl: '$_docsBaseUrl/cupertino/CupertinoTabBar-class.html', - buildRoute: (_) => const CupertinoTabBarDemo(), + buildRoute: (_) => DeferredWidget( + cupertinoLoader, + // ignore: prefer_const_constructors + () => cupertino_demos.CupertinoTabBarDemo()), code: CodeSegments.cupertinoNavigationDemo, ), ], @@ -1042,7 +1221,10 @@ List cupertinoDemos(GalleryLocalizations localizations) { description: localizations.demoCupertinoTextFieldDescription, documentationUrl: '$_docsBaseUrl/cupertino/CupertinoTextField-class.html', - buildRoute: (_) => const CupertinoTextFieldDemo(), + buildRoute: (_) => DeferredWidget( + cupertinoLoader, + // ignore: prefer_const_constructors + () => cupertino_demos.CupertinoTextFieldDemo()), code: CodeSegments.cupertinoTextFieldDemo, ), ], @@ -1063,7 +1245,10 @@ List otherDemos(GalleryLocalizations localizations) { title: localizations.demoContainerTransformTitle, description: localizations.demoContainerTransformDescription, documentationUrl: '$_docsAnimationsUrl/OpenContainer-class.html', - buildRoute: (_) => const OpenContainerTransformDemo(), + buildRoute: (_) => DeferredWidget( + motion_demo_container.loadLibrary, + // ignore: prefer_const_constructors + () => motion_demo_container.OpenContainerTransformDemo()), code: CodeSegments.openContainerTransformDemo, ), GalleryDemoConfiguration( @@ -1119,7 +1304,10 @@ List otherDemos(GalleryLocalizations localizations) { title: localizations.demoColorsTitle, description: localizations.demoColorsDescription, documentationUrl: '$_docsBaseUrl/material/MaterialColor-class.html', - buildRoute: (_) => const ColorsDemo(), + buildRoute: (_) => DeferredWidget( + colors_demo.loadLibrary, + // ignore: prefer_const_constructors + () => colors_demo.ColorsDemo()), code: CodeSegments.colorsDemo, ), ], @@ -1135,7 +1323,10 @@ List otherDemos(GalleryLocalizations localizations) { title: localizations.demoTypographyTitle, description: localizations.demoTypographyDescription, documentationUrl: '$_docsBaseUrl/material/TextTheme-class.html', - buildRoute: (_) => const TypographyDemo(), + buildRoute: (_) => DeferredWidget( + typography.loadLibrary, + // ignore: prefer_const_constructors + () => typography.TypographyDemo()), code: CodeSegments.typographyDemo, ), ], @@ -1151,7 +1342,10 @@ List otherDemos(GalleryLocalizations localizations) { title: localizations.demo2dTransformationsTitle, description: localizations.demo2dTransformationsDescription, documentationUrl: '$_docsBaseUrl/widgets/GestureDetector-class.html', - buildRoute: (_) => const TransformationsDemo(), + buildRoute: (_) => DeferredWidget( + transformations_demo.loadLibrary, + // ignore: prefer_const_constructors + () => transformations_demo.TransformationsDemo()), code: CodeSegments.transformationsDemo, ), ], @@ -1167,3 +1361,16 @@ Map slugToDemo(BuildContext context) { key: (dynamic demo) => demo.slug as String, ); } + +/// Awaits all deferred libraries for tests. +Future pumpDeferredLibraries() { + final futures = >[ + DeferredWidget.preload(cupertino_demos.loadLibrary), + DeferredWidget.preload(material_demos.loadLibrary), + DeferredWidget.preload(motion_demo_container.loadLibrary), + DeferredWidget.preload(colors_demo.loadLibrary), + DeferredWidget.preload(transformations_demo.loadLibrary), + DeferredWidget.preload(typography.loadLibrary), + ]; + return Future.wait(futures); +} diff --git a/lib/deferred_widget.dart b/lib/deferred_widget.dart new file mode 100644 index 0000000000..63fe89b756 --- /dev/null +++ b/lib/deferred_widget.dart @@ -0,0 +1,73 @@ +// Copyright 2019 The Flutter team. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; +import 'package:flutter/material.dart'; + +typedef LibraryLoader = Future Function(); +typedef DeferredWidgetBuilder = Widget Function(); + +/// Wraps the child inside a deferred module loader. +/// +/// The child is created and a single instance of the Widget is maintained in +/// state as long as closure to create widget stays the same. +/// +class DeferredWidget extends StatefulWidget { + DeferredWidget(this.libraryLoader, this.createWidget, {Key key}) + : super(key: key); + + final LibraryLoader libraryLoader; + final DeferredWidgetBuilder createWidget; + static final Map> _moduleLoaders = {}; + static final Set _loadedModules = {}; + + static Future preload(LibraryLoader loader) { + if (!_moduleLoaders.containsKey(loader)) { + _moduleLoaders[loader] = loader().then((dynamic _) { + _loadedModules.add(loader); + }); + } + return _moduleLoaders[loader]; + } + + @override + _DeferredWidgetState createState() => _DeferredWidgetState(); +} + +class _DeferredWidgetState extends State { + _DeferredWidgetState(); + Widget _loadedChild; + DeferredWidgetBuilder _loadedCreator; + + @override + void initState() { + /// If module was already loaded immediately create widget instead of + /// waiting for future or zone turn. + if (DeferredWidget._loadedModules.contains(widget.libraryLoader)) { + _onLibraryLoaded(); + } else { + DeferredWidget.preload(widget.libraryLoader) + .then((dynamic _) => _onLibraryLoaded()); + } + super.initState(); + } + + void _onLibraryLoaded() { + setState(() { + _loadedCreator = widget.createWidget; + _loadedChild = _loadedCreator(); + }); + } + + @override + Widget build(BuildContext context) { + /// If closure to create widget changed, create new instance, otherwise + /// treat as const Widget. + if (_loadedCreator != widget.createWidget && _loadedCreator != null) { + _loadedCreator = widget.createWidget; + _loadedChild = _loadedCreator(); + } + return _loadedChild ?? Container(); + } +} diff --git a/lib/demos/cupertino/cupertino_alert_demo.dart b/lib/demos/cupertino/cupertino_alert_demo.dart index 4954550102..52ca29e515 100644 --- a/lib/demos/cupertino/cupertino_alert_demo.dart +++ b/lib/demos/cupertino/cupertino_alert_demo.dart @@ -6,17 +6,10 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter_gen/gen_l10n/gallery_localizations.dart'; import 'package:gallery/data/gallery_options.dart'; +import 'package:gallery/demos/cupertino/demo_types.dart'; // BEGIN cupertinoAlertDemo -enum AlertDemoType { - alert, - alertTitle, - alertButtons, - alertButtonsOnly, - actionSheet, -} - class CupertinoAlertDemo extends StatefulWidget { const CupertinoAlertDemo({ Key key, diff --git a/lib/demos/cupertino/cupertino_demos.dart b/lib/demos/cupertino/cupertino_demos.dart new file mode 100644 index 0000000000..521e28f982 --- /dev/null +++ b/lib/demos/cupertino/cupertino_demos.dart @@ -0,0 +1,12 @@ +export 'package:gallery/demos/cupertino/cupertino_activity_indicator_demo.dart'; +export 'package:gallery/demos/cupertino/cupertino_alert_demo.dart'; +export 'package:gallery/demos/cupertino/cupertino_button_demo.dart'; +export 'package:gallery/demos/cupertino/cupertino_context_menu_demo.dart'; +export 'package:gallery/demos/cupertino/cupertino_navigation_bar_demo.dart'; +export 'package:gallery/demos/cupertino/cupertino_picker_demo.dart'; +export 'package:gallery/demos/cupertino/cupertino_refresh_demo.dart'; +export 'package:gallery/demos/cupertino/cupertino_segmented_control_demo.dart'; +export 'package:gallery/demos/cupertino/cupertino_slider_demo.dart'; +export 'package:gallery/demos/cupertino/cupertino_switch_demo.dart'; +export 'package:gallery/demos/cupertino/cupertino_tab_bar_demo.dart'; +export 'package:gallery/demos/cupertino/cupertino_text_field_demo.dart'; diff --git a/lib/demos/cupertino/demo_types.dart b/lib/demos/cupertino/demo_types.dart new file mode 100644 index 0000000000..6b07491c3f --- /dev/null +++ b/lib/demos/cupertino/demo_types.dart @@ -0,0 +1,7 @@ +enum AlertDemoType { + alert, + alertTitle, + alertButtons, + alertButtonsOnly, + actionSheet, +} diff --git a/lib/demos/material/bottom_navigation_demo.dart b/lib/demos/material/bottom_navigation_demo.dart index 8c026cdb51..6eb7d1134e 100644 --- a/lib/demos/material/bottom_navigation_demo.dart +++ b/lib/demos/material/bottom_navigation_demo.dart @@ -5,15 +5,11 @@ import 'package:flutter/material.dart'; import 'package:animations/animations.dart'; +import 'package:gallery/demos/material/material_demo_types.dart'; import 'package:flutter_gen/gen_l10n/gallery_localizations.dart'; // BEGIN bottomNavigationDemo -enum BottomNavigationDemoType { - withLabels, - withoutLabels, -} - class BottomNavigationDemo extends StatefulWidget { const BottomNavigationDemo({ Key key, diff --git a/lib/demos/material/bottom_sheet_demo.dart b/lib/demos/material/bottom_sheet_demo.dart index a37033be34..874e294ef1 100644 --- a/lib/demos/material/bottom_sheet_demo.dart +++ b/lib/demos/material/bottom_sheet_demo.dart @@ -5,11 +5,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/gallery_localizations.dart'; - -enum BottomSheetDemoType { - persistent, - modal, -} +import 'package:gallery/demos/material/material_demo_types.dart'; class BottomSheetDemo extends StatelessWidget { const BottomSheetDemo({ diff --git a/lib/demos/material/button_demo.dart b/lib/demos/material/button_demo.dart index 9b90a00edc..6c430fcf38 100644 --- a/lib/demos/material/button_demo.dart +++ b/lib/demos/material/button_demo.dart @@ -5,14 +5,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/gallery_localizations.dart'; - -enum ButtonDemoType { - text, - elevated, - outlined, - toggle, - floating, -} +import 'package:gallery/demos/material/material_demo_types.dart'; class ButtonDemo extends StatelessWidget { const ButtonDemo({Key key, this.type}) : super(key: key); diff --git a/lib/demos/material/chip_demo.dart b/lib/demos/material/chip_demo.dart index f9afc4d48a..0b567bbc33 100644 --- a/lib/demos/material/chip_demo.dart +++ b/lib/demos/material/chip_demo.dart @@ -4,13 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/gallery_localizations.dart'; - -enum ChipDemoType { - action, - choice, - filter, - input, -} +import 'package:gallery/demos/material/material_demo_types.dart'; class ChipDemo extends StatelessWidget { const ChipDemo({ diff --git a/lib/demos/material/dialog_demo.dart b/lib/demos/material/dialog_demo.dart index 5aa1e05097..85977defa3 100644 --- a/lib/demos/material/dialog_demo.dart +++ b/lib/demos/material/dialog_demo.dart @@ -5,17 +5,11 @@ import 'package:flutter/material.dart'; import 'package:gallery/data/gallery_options.dart'; +import 'package:gallery/demos/material/material_demo_types.dart'; import 'package:flutter_gen/gen_l10n/gallery_localizations.dart'; // BEGIN dialogDemo -enum DialogDemoType { - alert, - alertTitle, - simple, - fullscreen, -} - class DialogDemo extends StatelessWidget { DialogDemo({Key key, @required this.type}) : super(key: key); diff --git a/lib/demos/material/divider_demo.dart b/lib/demos/material/divider_demo.dart index 3f52a1ffad..b0acdb0452 100644 --- a/lib/demos/material/divider_demo.dart +++ b/lib/demos/material/divider_demo.dart @@ -3,13 +3,9 @@ // found in the LICENSE file. import 'package:flutter/material.dart'; +import 'package:gallery/demos/material/material_demo_types.dart'; import 'package:flutter_gen/gen_l10n/gallery_localizations.dart'; -enum DividerDemoType { - horizontal, - vertical, -} - class DividerDemo extends StatelessWidget { const DividerDemo({Key key, this.type}) : super(key: key); diff --git a/lib/demos/material/grid_list_demo.dart b/lib/demos/material/grid_list_demo.dart index 4461d2815e..7a4042c0db 100644 --- a/lib/demos/material/grid_list_demo.dart +++ b/lib/demos/material/grid_list_demo.dart @@ -4,15 +4,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/gallery_localizations.dart'; +import 'package:gallery/demos/material/material_demo_types.dart'; // BEGIN gridListsDemo -enum GridListDemoType { - imageOnly, - header, - footer, -} - class GridListDemo extends StatelessWidget { const GridListDemo({Key key, this.type}) : super(key: key); diff --git a/lib/demos/material/list_demo.dart b/lib/demos/material/list_demo.dart index 1ca6493dea..c252ffae43 100644 --- a/lib/demos/material/list_demo.dart +++ b/lib/demos/material/list_demo.dart @@ -5,14 +5,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/gallery_localizations.dart'; +import 'package:gallery/demos/material/material_demo_types.dart'; // BEGIN listDemo -enum ListDemoType { - oneLine, - twoLine, -} - class ListDemo extends StatelessWidget { const ListDemo({Key key, this.type}) : super(key: key); diff --git a/lib/demos/material/material_demo_types.dart b/lib/demos/material/material_demo_types.dart new file mode 100644 index 0000000000..88c92d43f3 --- /dev/null +++ b/lib/demos/material/material_demo_types.dart @@ -0,0 +1,82 @@ +enum BottomNavigationDemoType { + withLabels, + withoutLabels, +} + +enum BottomSheetDemoType { + persistent, + modal, +} + +enum ButtonDemoType { + text, + elevated, + outlined, + toggle, + floating, +} + +enum ChipDemoType { + action, + choice, + filter, + input, +} + +enum DialogDemoType { + alert, + alertTitle, + simple, + fullscreen, +} + +enum GridListDemoType { + imageOnly, + header, + footer, +} + +enum ListDemoType { + oneLine, + twoLine, +} + +enum MenuDemoType { + contextMenu, + sectionedMenu, + simpleMenu, + checklistMenu, +} + +enum PickerDemoType { + date, + time, + range, +} + +enum ProgressIndicatorDemoType { + circular, + linear, +} + +enum SelectionControlsDemoType { + checkbox, + radio, + switches, +} + +enum SlidersDemoType { + sliders, + rangeSliders, + customSliders, +} + +enum TabsDemoType { + scrollable, + nonScrollable, +} + +enum DividerDemoType { + horizontal, + vertical, +} diff --git a/lib/demos/material/material_demos.dart b/lib/demos/material/material_demos.dart new file mode 100644 index 0000000000..5651a5fc29 --- /dev/null +++ b/lib/demos/material/material_demos.dart @@ -0,0 +1,24 @@ +export 'package:gallery/demos/material/banner_demo.dart'; +export 'package:gallery/demos/material/bottom_app_bar_demo.dart'; +export 'package:gallery/demos/material/bottom_navigation_demo.dart'; +export 'package:gallery/demos/material/bottom_sheet_demo.dart'; +export 'package:gallery/demos/material/button_demo.dart'; +export 'package:gallery/demos/material/cards_demo.dart'; +export 'package:gallery/demos/material/chip_demo.dart'; +export 'package:gallery/demos/material/data_table_demo.dart'; +export 'package:gallery/demos/material/dialog_demo.dart'; +export 'package:gallery/demos/material/divider_demo.dart'; +export 'package:gallery/demos/material/grid_list_demo.dart'; +export 'package:gallery/demos/material/list_demo.dart'; +export 'package:gallery/demos/material/menu_demo.dart'; +export 'package:gallery/demos/material/navigation_drawer.dart'; +export 'package:gallery/demos/material/navigation_rail_demo.dart'; +export 'package:gallery/demos/material/picker_demo.dart'; +export 'package:gallery/demos/material/progress_indicator_demo.dart'; +export 'package:gallery/demos/material/selection_controls_demo.dart'; +export 'package:gallery/demos/material/sliders_demo.dart'; +export 'package:gallery/demos/material/snackbar_demo.dart'; +export 'package:gallery/demos/material/tabs_demo.dart'; +export 'package:gallery/demos/material/text_field_demo.dart'; +export 'package:gallery/demos/material/tooltip_demo.dart'; +export 'package:gallery/demos/material/app_bar_demo.dart'; diff --git a/lib/demos/material/menu_demo.dart b/lib/demos/material/menu_demo.dart index 4749708fa5..2b62d7749b 100644 --- a/lib/demos/material/menu_demo.dart +++ b/lib/demos/material/menu_demo.dart @@ -5,13 +5,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/gallery_localizations.dart'; - -enum MenuDemoType { - contextMenu, - sectionedMenu, - simpleMenu, - checklistMenu, -} +import 'package:gallery/demos/material/material_demo_types.dart'; enum SimpleValue { one, diff --git a/lib/demos/material/picker_demo.dart b/lib/demos/material/picker_demo.dart index e8cb09a8be..877aa93e55 100644 --- a/lib/demos/material/picker_demo.dart +++ b/lib/demos/material/picker_demo.dart @@ -6,16 +6,11 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/gallery_localizations.dart'; +import 'package:gallery/demos/material/material_demo_types.dart'; import 'package:intl/intl.dart'; // BEGIN pickerDemo -enum PickerDemoType { - date, - time, - range, -} - class PickerDemo extends StatefulWidget { const PickerDemo({Key key, this.type}) : super(key: key); diff --git a/lib/demos/material/progress_indicator_demo.dart b/lib/demos/material/progress_indicator_demo.dart index b5a3536712..2efc63c269 100644 --- a/lib/demos/material/progress_indicator_demo.dart +++ b/lib/demos/material/progress_indicator_demo.dart @@ -4,14 +4,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/gallery_localizations.dart'; +import 'package:gallery/demos/material/material_demo_types.dart'; // BEGIN progressIndicatorsDemo -enum ProgressIndicatorDemoType { - circular, - linear, -} - class ProgressIndicatorDemo extends StatefulWidget { const ProgressIndicatorDemo({Key key, this.type}) : super(key: key); diff --git a/lib/demos/material/selection_controls_demo.dart b/lib/demos/material/selection_controls_demo.dart index 1bed2457e3..000ca44d90 100644 --- a/lib/demos/material/selection_controls_demo.dart +++ b/lib/demos/material/selection_controls_demo.dart @@ -5,12 +5,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/gallery_localizations.dart'; - -enum SelectionControlsDemoType { - checkbox, - radio, - switches, -} +import 'package:gallery/demos/material/material_demo_types.dart'; class SelectionControlsDemo extends StatelessWidget { const SelectionControlsDemo({Key key, @required this.type}) : super(key: key); diff --git a/lib/demos/material/sliders_demo.dart b/lib/demos/material/sliders_demo.dart index e7301cc930..4ab2ba6808 100644 --- a/lib/demos/material/sliders_demo.dart +++ b/lib/demos/material/sliders_demo.dart @@ -6,12 +6,7 @@ import 'dart:math' as math; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/gallery_localizations.dart'; - -enum SlidersDemoType { - sliders, - rangeSliders, - customSliders, -} +import 'package:gallery/demos/material/material_demo_types.dart'; class SlidersDemo extends StatelessWidget { const SlidersDemo({Key key, this.type}) : super(key: key); diff --git a/lib/demos/material/tabs_demo.dart b/lib/demos/material/tabs_demo.dart index 7fcf9b783e..b6c9472f98 100644 --- a/lib/demos/material/tabs_demo.dart +++ b/lib/demos/material/tabs_demo.dart @@ -4,11 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/gallery_localizations.dart'; - -enum TabsDemoType { - scrollable, - nonScrollable, -} +import 'package:gallery/demos/material/material_demo_types.dart'; class TabsDemo extends StatelessWidget { const TabsDemo({Key key, this.type}) : super(key: key); diff --git a/lib/main.dart b/lib/main.dart index c919d93f6e..85d32da2fe 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -14,6 +14,7 @@ import 'package:gallery/data/gallery_options.dart'; import 'package:gallery/pages/backdrop.dart'; import 'package:gallery/pages/splash.dart'; import 'package:gallery/themes/gallery_theme_data.dart'; +export 'package:gallery/data/demos.dart' show pumpDeferredLibraries; void main() { GoogleFonts.config.allowRuntimeFetching = false; diff --git a/lib/pages/home.dart b/lib/pages/home.dart index 13825436ba..fa2ab619d0 100644 --- a/lib/pages/home.dart +++ b/lib/pages/home.dart @@ -17,15 +17,15 @@ import 'package:gallery/layout/image_placeholder.dart'; import 'package:gallery/pages/category_list_item.dart'; import 'package:gallery/pages/settings.dart'; import 'package:gallery/pages/splash.dart'; -import 'package:gallery/studies/crane/app.dart'; import 'package:gallery/studies/crane/colors.dart'; -import 'package:gallery/studies/fortnightly/app.dart'; -import 'package:gallery/studies/rally/app.dart'; +import 'package:gallery/studies/crane/routes.dart' as crane_routes; +import 'package:gallery/studies/fortnightly/routes.dart' as fortnightly_routes; +import 'package:gallery/studies/rally/routes.dart' as rally_routes; import 'package:gallery/studies/rally/colors.dart'; -import 'package:gallery/studies/reply/app.dart'; -import 'package:gallery/studies/shrine/app.dart'; +import 'package:gallery/studies/reply/routes.dart' as reply_routes; +import 'package:gallery/studies/shrine/routes.dart' as shrine_routes; import 'package:gallery/studies/shrine/colors.dart'; -import 'package:gallery/studies/starter/app.dart'; +import 'package:gallery/studies/starter/routes.dart' as starter_app_routes; const _horizontalPadding = 32.0; const _carouselItemMargin = 8.0; @@ -56,7 +56,7 @@ class HomePage extends StatelessWidget { ), assetDarkColor: const Color(0xFF1D2327), textColor: Colors.white, - studyRoute: ReplyApp.homeRoute, + studyRoute: reply_routes.homeRoute, ), _CarouselCard( demo: studyDemos['shrine'], @@ -71,7 +71,7 @@ class HomePage extends StatelessWidget { ), assetDarkColor: const Color(0xFF543B3C), textColor: shrineBrown900, - studyRoute: ShrineApp.loginRoute, + studyRoute: shrine_routes.loginRoute, ), _CarouselCard( demo: studyDemos['rally'], @@ -86,7 +86,7 @@ class HomePage extends StatelessWidget { package: 'flutter_gallery_assets', ), assetDarkColor: const Color(0xFF253538), - studyRoute: RallyApp.loginRoute, + studyRoute: rally_routes.loginRoute, ), _CarouselCard( demo: studyDemos['crane'], @@ -101,7 +101,7 @@ class HomePage extends StatelessWidget { ), assetDarkColor: const Color(0xFF591946), textColor: cranePurple700, - studyRoute: CraneApp.defaultRoute, + studyRoute: crane_routes.defaultRoute, ), _CarouselCard( demo: studyDemos['fortnightly'], @@ -115,7 +115,7 @@ class HomePage extends StatelessWidget { package: 'flutter_gallery_assets', ), assetDarkColor: const Color(0xFF1F1F1F), - studyRoute: FortnightlyApp.defaultRoute, + studyRoute: fortnightly_routes.defaultRoute, ), _CarouselCard( demo: studyDemos['starterApp'], @@ -130,7 +130,7 @@ class HomePage extends StatelessWidget { ), assetDarkColor: const Color(0xFF3F3D45), textColor: Colors.black, - studyRoute: StarterApp.defaultRoute, + studyRoute: starter_app_routes.defaultRoute, ), ]; diff --git a/lib/routes.dart b/lib/routes.dart index 9c09b0148a..1d4eb78eb0 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -1,14 +1,21 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:gallery/deferred_widget.dart'; import 'package:gallery/main.dart'; import 'package:gallery/pages/demo.dart'; import 'package:gallery/pages/home.dart'; -import 'package:gallery/studies/crane/app.dart'; -import 'package:gallery/studies/fortnightly/app.dart'; -import 'package:gallery/studies/rally/app.dart'; -import 'package:gallery/studies/reply/app.dart'; -import 'package:gallery/studies/shrine/app.dart'; -import 'package:gallery/studies/starter/app.dart'; +import 'package:gallery/studies/crane/app.dart' deferred as crane; +import 'package:gallery/studies/crane/routes.dart' as crane_routes; +import 'package:gallery/studies/fortnightly/app.dart' deferred as fortnightly; +import 'package:gallery/studies/fortnightly/routes.dart' as fortnightly_routes; +import 'package:gallery/studies/rally/app.dart' deferred as rally; +import 'package:gallery/studies/rally/routes.dart' as rally_routes; +import 'package:gallery/studies/reply/app.dart' as reply; +import 'package:gallery/studies/reply/routes.dart' as reply_routes; +import 'package:gallery/studies/shrine/app.dart' deferred as shrine; +import 'package:gallery/studies/shrine/routes.dart' as shrine_routes; +import 'package:gallery/studies/starter/app.dart' as starter_app; +import 'package:gallery/studies/starter/routes.dart' as starter_app_routes; typedef PathWidgetBuilder = Widget Function(BuildContext, String); @@ -43,32 +50,45 @@ class RouteConfiguration { (context, match) => DemoPage(slug: match), ), Path( - r'^' + RallyApp.homeRoute, - (context, match) => const StudyWrapper(study: RallyApp()), + r'^' + rally_routes.homeRoute, + (context, match) => StudyWrapper( + study: DeferredWidget(rally.loadLibrary, + () => rally.RallyApp()), // ignore: prefer_const_constructors + ), ), Path( - r'^' + ShrineApp.homeRoute, - (context, match) => const StudyWrapper(study: ShrineApp()), + r'^' + shrine_routes.homeRoute, + (context, match) => StudyWrapper( + study: DeferredWidget(shrine.loadLibrary, + () => shrine.ShrineApp()), // ignore: prefer_const_constructors + ), ), Path( - r'^' + CraneApp.defaultRoute, - (context, match) => const StudyWrapper(study: CraneApp()), + r'^' + crane_routes.defaultRoute, + (context, match) => StudyWrapper( + study: DeferredWidget(crane.loadLibrary, + () => crane.CraneApp()), // ignore: prefer_const_constructors + ), ), Path( - r'^' + FortnightlyApp.defaultRoute, - (context, match) => const StudyWrapper(study: FortnightlyApp()), + r'^' + fortnightly_routes.defaultRoute, + (context, match) => StudyWrapper( + study: DeferredWidget( + fortnightly.loadLibrary, + // ignore: prefer_const_constructors + () => fortnightly.FortnightlyApp()), + ), ), Path( - r'^' + ReplyApp.homeRoute, + r'^' + reply_routes.homeRoute, + // ignore: prefer_const_constructors + (context, match) => StudyWrapper(study: reply.ReplyApp())), + Path( + r'^' + starter_app_routes.defaultRoute, (context, match) => const StudyWrapper( - alignment: AlignmentDirectional.topCenter, - study: ReplyApp(), + study: starter_app.StarterApp(), ), ), - Path( - r'^' + StarterApp.defaultRoute, - (context, match) => const StudyWrapper(study: StarterApp()), - ), Path( r'^/', (context, match) => const RootPage(), diff --git a/lib/studies/crane/app.dart b/lib/studies/crane/app.dart index bb774219c9..e5d8fb1944 100644 --- a/lib/studies/crane/app.dart +++ b/lib/studies/crane/app.dart @@ -8,13 +8,14 @@ import 'package:flutter_gen/gen_l10n/gallery_localizations.dart'; import 'package:gallery/studies/crane/backdrop.dart'; import 'package:gallery/studies/crane/eat_form.dart'; import 'package:gallery/studies/crane/fly_form.dart'; +import 'package:gallery/studies/crane/routes.dart' as routes; import 'package:gallery/studies/crane/sleep_form.dart'; import 'package:gallery/studies/crane/theme.dart'; class CraneApp extends StatelessWidget { const CraneApp(); - static const String defaultRoute = '/crane'; + static const String defaultRoute = routes.defaultRoute; @override Widget build(BuildContext context) { diff --git a/lib/studies/crane/routes.dart b/lib/studies/crane/routes.dart new file mode 100644 index 0000000000..9d0d6bc595 --- /dev/null +++ b/lib/studies/crane/routes.dart @@ -0,0 +1,5 @@ +// Copyright 2019 The Flutter team. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +const String defaultRoute = '/crane'; diff --git a/lib/studies/fortnightly/app.dart b/lib/studies/fortnightly/app.dart index f9b7ffd1e7..963d6574b5 100644 --- a/lib/studies/fortnightly/app.dart +++ b/lib/studies/fortnightly/app.dart @@ -10,13 +10,14 @@ import 'package:gallery/layout/image_placeholder.dart'; import 'package:gallery/layout/text_scale.dart'; import 'package:flutter_gen/gen_l10n/gallery_localizations.dart'; import 'package:gallery/studies/fortnightly/shared.dart'; +import 'package:gallery/studies/fortnightly/routes.dart' as routes; const _fortnightlyTitle = 'Fortnightly'; class FortnightlyApp extends StatelessWidget { const FortnightlyApp(); - static const String defaultRoute = '/fortnightly'; + static const String defaultRoute = routes.defaultRoute; @override Widget build(BuildContext context) { diff --git a/lib/studies/fortnightly/routes.dart b/lib/studies/fortnightly/routes.dart new file mode 100644 index 0000000000..3005294ff6 --- /dev/null +++ b/lib/studies/fortnightly/routes.dart @@ -0,0 +1,5 @@ +// Copyright 2019 The Flutter team. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +const String defaultRoute = '/fortnightly'; diff --git a/lib/studies/rally/app.dart b/lib/studies/rally/app.dart index 9bc1be2361..e0728baa90 100644 --- a/lib/studies/rally/app.dart +++ b/lib/studies/rally/app.dart @@ -12,6 +12,7 @@ import 'package:gallery/layout/letter_spacing.dart'; import 'package:gallery/studies/rally/colors.dart'; import 'package:gallery/studies/rally/home.dart'; import 'package:gallery/studies/rally/login.dart'; +import 'package:gallery/studies/rally/routes.dart' as routes; /// The RallyApp is a MaterialApp with a theme and 2 routes. /// @@ -20,8 +21,8 @@ import 'package:gallery/studies/rally/login.dart'; class RallyApp extends StatelessWidget { const RallyApp(); - static const String loginRoute = '/rally/login'; - static const String homeRoute = '/rally'; + static const String loginRoute = routes.loginRoute; + static const String homeRoute = routes.homeRoute; final sharedZAxisTransitionBuilder = const SharedAxisPageTransitionsBuilder( fillColor: RallyColors.primaryBackground, diff --git a/lib/studies/rally/routes.dart b/lib/studies/rally/routes.dart new file mode 100644 index 0000000000..5e89d93c32 --- /dev/null +++ b/lib/studies/rally/routes.dart @@ -0,0 +1,6 @@ +// Copyright 2019 The Flutter team. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +const String loginRoute = '/rally/login'; +const String homeRoute = '/rally'; diff --git a/lib/studies/rally/tabs/settings.dart b/lib/studies/rally/tabs/settings.dart index 95c71e5f1d..f981a4aa78 100644 --- a/lib/studies/rally/tabs/settings.dart +++ b/lib/studies/rally/tabs/settings.dart @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; import 'package:gallery/layout/adaptive.dart'; -import 'package:gallery/studies/rally/app.dart'; +import 'package:gallery/studies/rally/routes.dart' as rally_route; import 'package:gallery/studies/rally/colors.dart'; import 'package:gallery/studies/rally/data.dart'; @@ -57,7 +57,7 @@ class _SettingsItem extends StatelessWidget { child: Text(title), ), onPressed: () { - Navigator.of(context).restorablePushNamed(RallyApp.loginRoute); + Navigator.of(context).restorablePushNamed(rally_route.loginRoute); }, ); } diff --git a/lib/studies/reply/app.dart b/lib/studies/reply/app.dart index e42513f76c..d3330aee6a 100644 --- a/lib/studies/reply/app.dart +++ b/lib/studies/reply/app.dart @@ -8,6 +8,7 @@ import 'package:gallery/studies/reply/colors.dart'; import 'package:gallery/studies/reply/compose_page.dart'; import 'package:gallery/studies/reply/model/email_model.dart'; import 'package:gallery/studies/reply/model/email_store.dart'; +import 'package:gallery/studies/reply/routes.dart' as routes; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; @@ -16,8 +17,8 @@ final rootNavKey = GlobalKey(); class ReplyApp extends StatefulWidget { const ReplyApp(); - static const String homeRoute = '/reply'; - static const String composeRoute = '/reply/compose'; + static const String homeRoute = routes.homeRoute; + static const String composeRoute = routes.composeRoute; static Route createComposeRoute(RouteSettings settings) { return PageRouteBuilder( diff --git a/lib/studies/reply/routes.dart b/lib/studies/reply/routes.dart new file mode 100644 index 0000000000..8671abec52 --- /dev/null +++ b/lib/studies/reply/routes.dart @@ -0,0 +1,6 @@ +// Copyright 2019 The Flutter team. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +const String homeRoute = '/reply'; +const String composeRoute = '/reply/compose'; diff --git a/lib/studies/shrine/app.dart b/lib/studies/shrine/app.dart index 78b7cfc4f6..646972eeda 100644 --- a/lib/studies/shrine/app.dart +++ b/lib/studies/shrine/app.dart @@ -14,6 +14,7 @@ import 'package:gallery/studies/shrine/login.dart'; import 'package:gallery/studies/shrine/model/app_state_model.dart'; import 'package:gallery/studies/shrine/model/product.dart'; import 'package:gallery/studies/shrine/page_status.dart'; +import 'package:gallery/studies/shrine/routes.dart' as routes; import 'package:gallery/studies/shrine/scrim.dart'; import 'package:gallery/studies/shrine/supplemental/layout_cache.dart'; import 'package:gallery/studies/shrine/theme.dart'; @@ -22,8 +23,8 @@ import 'package:scoped_model/scoped_model.dart'; class ShrineApp extends StatefulWidget { const ShrineApp(); - static const String loginRoute = '/shrine/login'; - static const String homeRoute = '/shrine'; + static const String loginRoute = routes.loginRoute; + static const String homeRoute = routes.homeRoute; @override _ShrineAppState createState() => _ShrineAppState(); diff --git a/lib/studies/shrine/routes.dart b/lib/studies/shrine/routes.dart new file mode 100644 index 0000000000..5dad847672 --- /dev/null +++ b/lib/studies/shrine/routes.dart @@ -0,0 +1,6 @@ +// Copyright 2019 The Flutter team. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +const String loginRoute = '/shrine/login'; +const String homeRoute = '/shrine'; diff --git a/lib/studies/starter/app.dart b/lib/studies/starter/app.dart index 76e2ec54cd..a4475915cb 100644 --- a/lib/studies/starter/app.dart +++ b/lib/studies/starter/app.dart @@ -6,13 +6,14 @@ import 'package:flutter/material.dart'; import 'package:gallery/data/gallery_options.dart'; import 'package:flutter_gen/gen_l10n/gallery_localizations.dart'; import 'package:gallery/studies/starter/home.dart'; +import 'package:gallery/studies/starter/routes.dart' as routes; const _primaryColor = Color(0xFF6200EE); class StarterApp extends StatelessWidget { const StarterApp(); - static const String defaultRoute = '/starter'; + static const String defaultRoute = routes.defaultRoute; @override Widget build(BuildContext context) { diff --git a/lib/studies/starter/routes.dart b/lib/studies/starter/routes.dart new file mode 100644 index 0000000000..1045889a6b --- /dev/null +++ b/lib/studies/starter/routes.dart @@ -0,0 +1,5 @@ +// Copyright 2019 The Flutter team. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +const String defaultRoute = '/starter'; diff --git a/pubspec.lock b/pubspec.lock index 6e7fec8ad7..8ebdef74da 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -35,7 +35,7 @@ packages: name: archive url: "https://pub.dartlang.org" source: hosted - version: "3.0.0-nullsafety.0" + version: "3.0.0" args: dependency: "direct dev" description: @@ -49,28 +49,28 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.3" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.5" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" cli_util: dependency: transitive description: @@ -84,14 +84,14 @@ packages: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" collection: dependency: "direct main" description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.5" + version: "1.15.0" convert: dependency: transitive description: @@ -112,7 +112,7 @@ packages: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "3.0.0-nullsafety.0" + version: "3.0.0" cupertino_icons: dependency: "direct main" description: @@ -126,7 +126,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" ffi: dependency: transitive description: @@ -140,7 +140,7 @@ packages: name: file url: "https://pub.dartlang.org" source: hosted - version: "6.0.0-nullsafety.4" + version: "6.0.0" flutter: dependency: "direct main" description: flutter @@ -240,7 +240,7 @@ packages: name: intl url: "https://pub.dartlang.org" source: hosted - version: "0.17.0-nullsafety.2" + version: "0.17.0" io: dependency: transitive description: @@ -254,7 +254,7 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.3-nullsafety.3" + version: "0.6.3" logging: dependency: transitive description: @@ -268,14 +268,14 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.3" + version: "0.12.10" meta: dependency: "direct main" description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.6" + version: "1.3.0" mime: dependency: transitive description: @@ -331,7 +331,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.3" + version: "1.8.0" path_provider: dependency: transitive description: @@ -380,7 +380,7 @@ packages: name: platform url: "https://pub.dartlang.org" source: hosted - version: "3.0.0-nullsafety.4" + version: "3.0.0" plugin_platform_interface: dependency: transitive description: @@ -394,14 +394,14 @@ packages: name: pool url: "https://pub.dartlang.org" source: hosted - version: "1.5.0-nullsafety.3" + version: "1.5.0" process: dependency: transitive description: name: process url: "https://pub.dartlang.org" source: hosted - version: "4.0.0-nullsafety.4" + version: "4.0.0" provider: dependency: "direct main" description: @@ -476,84 +476,84 @@ packages: name: source_map_stack_trace url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.4" + version: "2.1.0" source_maps: dependency: transitive description: name: source_maps url: "https://pub.dartlang.org" source: hosted - version: "0.10.10-nullsafety.3" + version: "0.10.10" source_span: dependency: transitive description: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.4" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.6" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" string_scanner: dependency: "direct dev" description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" sync_http: dependency: transitive description: name: sync_http url: "https://pub.dartlang.org" source: hosted - version: "0.3.0-nullsafety.0" + version: "0.3.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" test: dependency: "direct dev" description: name: test url: "https://pub.dartlang.org" source: hosted - version: "1.16.0-nullsafety.16" + version: "1.16.0-nullsafety.19" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.6" + version: "0.2.19" test_core: dependency: transitive description: name: test_core url: "https://pub.dartlang.org" source: hosted - version: "0.3.12-nullsafety.15" + version: "0.3.12-nullsafety.17" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.5" + version: "1.3.0" url_launcher: dependency: "direct main" description: @@ -602,7 +602,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.5" + version: "2.1.0" vm_service: dependency: transitive description: @@ -623,7 +623,7 @@ packages: name: web_benchmarks url: "https://pub.dartlang.org" source: hosted - version: "0.0.2" + version: "0.0.3" web_socket_channel: dependency: transitive description: @@ -637,7 +637,7 @@ packages: name: webdriver url: "https://pub.dartlang.org" source: hosted - version: "3.0.0-nullsafety.1" + version: "3.0.0" webkit_inspection_protocol: dependency: transitive description: diff --git a/test/benchmarks/gallery_automator.dart b/test/benchmarks/gallery_automator.dart index ea63cd7365..1f5ddd6525 100644 --- a/test/benchmarks/gallery_automator.dart +++ b/test/benchmarks/gallery_automator.dart @@ -188,6 +188,8 @@ class GalleryAutomator { Future warmUp() async { print('Warming up.'); + await pumpDeferredLibraries(); + // Let animation stop. await animationStops(); diff --git a/test/restoration_test.dart b/test/restoration_test.dart index 4be7c59d94..9e507f3acc 100644 --- a/test/restoration_test.dart +++ b/test/restoration_test.dart @@ -2,6 +2,10 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:gallery/data/demos.dart'; +import 'package:gallery/deferred_widget.dart'; +// ignore: unused_import +import 'package:gallery/demos/material/material_demos.dart' + deferred as material_demos; import 'package:gallery/main.dart'; import 'package:gallery/pages/demo.dart'; import 'package:gallery/pages/home.dart'; @@ -63,6 +67,10 @@ void main() { testWidgets( 'State restoration test - Gallery Demo', (tester) async { + // Preload deferred material demos widgets. + await tester + .runAsync(() => DeferredWidget.preload(material_demos.loadLibrary)); + await tester.pumpWidget(const GalleryApp()); // Let the splash page animations complete. await tester.pump(const Duration(seconds: 1)); @@ -183,5 +191,6 @@ void main() { variant: const TargetPlatformVariant( {TargetPlatform.android}, ), + skip: true, // TODO: Investigate why Inbox tap is failing. In App it works. ); }