Skip to content

Commit eba4dd1

Browse files
committed
Document Example
1 parent ef50034 commit eba4dd1

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

lib/main.dart

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class MyApp extends StatelessWidget {
1414
@override
1515
Widget build(BuildContext context) {
1616
return MaterialApp(
17+
// Make breakpoint values accessible throughout the app by wrapping the
18+
// app with a builder method.
1719
builder: (context, child) => ResponsiveBreakpoints.builder(
1820
child: child!,
1921
breakpoints: [
@@ -24,21 +26,34 @@ class MyApp extends StatelessWidget {
2426
],
2527
),
2628
initialRoute: '/',
29+
// The following code demonstrates an implementation of the AutoScale functionality
30+
// of ResponsiveScaledBox. The ResponsiveScaledBox widget preserves
31+
// the legacy ResponsiveWrapper behavior, scaling the UI instead of resizing.
2732
onGenerateRoute: (RouteSettings settings) {
33+
// A custom `fadeThrough` route transition animation.
2834
return Routes.fadeThrough(settings, (context) {
35+
// Wrap widgets with another widget based on the route.
36+
// Wrap the page with ResponsiveScaledBox on desired pages.
2937
return ConditionalRouteWidget(
30-
routesExcluded: const [],
38+
routesExcluded: const [
39+
TypographyPage.name
40+
], // An example of excluding a page from AutoScale.
3141
builder: (context, child) => MaxWidthBox(
42+
// A widget that limits the maximum width.
43+
// This is used to create a gutter area on either side of the content.
3244
maxWidth: 1200,
3345
background: Container(color: const Color(0xFFF5F5F5)),
3446
child: ResponsiveScaledBox(
47+
// ResponsiveScaledBox renders it's child with a FittedBox set to the `width` value.
48+
// Set the fixed width value based on the active breakpoint.
3549
width: ResponsiveValue<double>(context,
3650
conditionalValues: [
3751
const Condition.equals(name: MOBILE, value: 450),
3852
const Condition.between(
3953
start: 800, end: 1100, value: 800),
4054
const Condition.between(
4155
start: 1000, end: 1200, value: 1000),
56+
// Because the `maxWidth` is set to 1200 via the MaxWidthBox, the layout cannot expand over 1200px.
4257
]).value,
4358
child: child!),
4459
),
@@ -50,6 +65,8 @@ class MyApp extends StatelessWidget {
5065
);
5166
}
5267

68+
// onGenerateRoute route switcher.
69+
// Navigate using the page name, `Navigator.pushNamed(context, ListPage.name)`.
5370
Widget buildPage(String name) {
5471
switch (name) {
5572
case '/':

0 commit comments

Comments
 (0)