11import 'package:flutter/material.dart' ;
22import 'package:minimal/pages/pages.dart' ;
3- import 'package:minimal/routes.dart' ;
4- import 'package:navigation_utils/navigation_utils.dart' ;
53import 'package:responsive_framework/responsive_framework.dart' ;
6- import 'package:minimal/utils/conditional_route_widget.dart' ;
74
85void main () {
96 runApp (const MyApp ());
@@ -27,44 +24,34 @@ class MyApp extends StatelessWidget {
2724 ],
2825 ),
2926 initialRoute: '/' ,
30- // The following code implements the legacy ResponsiveWrapper AutoScale functionality
31- // using the new ResponsiveScaledBox. The ResponsiveScaledBox widget preserves
32- // the legacy ResponsiveWrapper behavior, scaling the UI instead of resizing.
33- //
34- // A ConditionalRouteWidget is used to showcase how to disable the AutoScale
35- // behavior for a page.
3627 onGenerateRoute: (RouteSettings settings) {
37- // A custom `fadeThrough` route transition animation.
38- return Routes .fadeThrough (settings, (context) {
39- // Wrap widgets with another widget based on the route.
40- // Wrap the page with the ResponsiveScaledBox for desired pages.
41- return ConditionalRouteWidget (
42- routesExcluded: const [
43- TypographyPage .name
44- ], // Excluding a page from AutoScale.
45- builder: (context, child) => MaxWidthBox (
46- // A widget that limits the maximum width.
47- // This is used to create a gutter area on either side of the content.
48- maxWidth: 1200 ,
49- background: Container (color: const Color (0xFFF5F5F5 )),
50- child: ResponsiveScaledBox (
51- // ResponsiveScaledBox renders its child with a FittedBox set to the `width` value.
52- // Set the fixed width value based on the active breakpoint.
53- width: ResponsiveValue <double >(context,
54- conditionalValues: [
55- const Condition .equals (name: MOBILE , value: 450 ),
56- const Condition .between (
57- start: 800 , end: 1100 , value: 800 ),
58- const Condition .between (
59- start: 1000 , end: 1200 , value: 1000 ),
60- // There are no conditions for width over 1200
61- // because the `maxWidth` is set to 1200 via the MaxWidthBox.
62- ]).value,
63- child: child! ),
64- ),
28+ return MaterialPageRoute (builder: (context) {
29+ // The following code implements the legacy ResponsiveWrapper AutoScale functionality
30+ // using the new ResponsiveScaledBox. The ResponsiveScaledBox widget preserves
31+ // the legacy ResponsiveWrapper behavior, scaling the UI instead of resizing.
32+ //
33+ // **MaxWidthBox** - A widget that limits the maximum width.
34+ // This is used to create a gutter area on either side of the content.
35+ //
36+ // **ResponsiveScaledBox** - A widget that renders its child
37+ // with a FittedBox set to the `width` value. Set the fixed width value
38+ // based on the active breakpoint.
39+ return MaxWidthBox (
40+ maxWidth: 1200 ,
41+ background: Container (color: const Color (0xFFF5F5F5 )),
42+ child: ResponsiveScaledBox (
43+ width: ResponsiveValue <double >(context, conditionalValues: [
44+ const Condition .equals (name: MOBILE , value: 450 ),
45+ const Condition .between (start: 800 , end: 1100 , value: 800 ),
46+ const Condition .between (start: 1000 , end: 1200 , value: 1000 ),
47+ // There are no conditions for width over 1200
48+ // because the `maxWidth` is set to 1200 via the MaxWidthBox.
49+ ]).value,
6550 child: BouncingScrollWrapper .builder (
6651 context, buildPage (settings.name ?? '' ),
67- dragWithMouse: true ));
52+ dragWithMouse: true ),
53+ ),
54+ );
6855 });
6956 },
7057 debugShowCheckedModeBanner: false ,
0 commit comments