Skip to content

Commit

Permalink
Simplify Example #2
Browse files Browse the repository at this point in the history
  • Loading branch information
rayliverified committed Sep 11, 2023
1 parent 74225a7 commit 6841d70
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 32 deletions.
36 changes: 9 additions & 27 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,9 @@ class MyApp extends StatelessWidget {
initialRoute: '/',
onGenerateRoute: (RouteSettings settings) {
return MaterialPageRoute(builder: (context) {
// The following code implements the legacy ResponsiveWrapper AutoScale functionality
// using the new ResponsiveScaledBox. The ResponsiveScaledBox widget preserves
// the legacy ResponsiveWrapper behavior, scaling the UI instead of resizing.
//
// **MaxWidthBox** - A widget that limits the maximum width.
// This is used to create a gutter area on either side of the content.
//
// **ResponsiveScaledBox** - A widget that renders its child
// with a FittedBox set to the `width` value. Set the fixed width value
// based on the active breakpoint.
return MaxWidthBox(
maxWidth: 1200,
background: Container(color: const Color(0xFFF5F5F5)),
child: ResponsiveScaledBox(
width: ResponsiveValue<double>(context, conditionalValues: [
Condition.equals(name: MOBILE, value: 450),
Condition.between(start: 800, end: 1100, value: 800),
Condition.between(start: 1000, end: 1200, value: 1000),
// There are no conditions for width over 1200
// because the `maxWidth` is set to 1200 via the MaxWidthBox.
]).value,
child: BouncingScrollWrapper.builder(
context, buildPage(settings.name ?? ''),
dragWithMouse: true),
),
);
return BouncingScrollWrapper.builder(
context, buildPage(settings.name ?? ''),
dragWithMouse: true);
});
},
debugShowCheckedModeBanner: false,
Expand All @@ -66,7 +43,12 @@ class MyApp extends StatelessWidget {
case ListPage.name:
return const ListPage();
case PostPage.name:
return const PostPage();
// Custom "per-page" breakpoints.
return const ResponsiveBreakpoints(breakpoints: [
Breakpoint(start: 0, end: 480, name: MOBILE),
Breakpoint(start: 481, end: 1200, name: TABLET),
Breakpoint(start: 1201, end: double.infinity, name: DESKTOP),
], child: PostPage());
case TypographyPage.name:
return const TypographyPage();
default:
Expand Down
7 changes: 7 additions & 0 deletions windows/runner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ add_executable(${BINARY_NAME} WIN32
# that need different build settings.
apply_standard_settings(${BINARY_NAME})

# Add preprocessor definitions for the build version.
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}")

# Disable Windows macros that collide with C++ standard library functions.
target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")

Expand Down
10 changes: 5 additions & 5 deletions windows/runner/Runner.rc
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ IDI_APP_ICON ICON "resources\\app_icon.ico"
// Version
//

#ifdef FLUTTER_BUILD_NUMBER
#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER
#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD)
#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD
#else
#define VERSION_AS_NUMBER 1,0,0
#define VERSION_AS_NUMBER 1,0,0,0
#endif

#ifdef FLUTTER_BUILD_NAME
#define VERSION_AS_STRING #FLUTTER_BUILD_NAME
#if defined(FLUTTER_VERSION)
#define VERSION_AS_STRING FLUTTER_VERSION
#else
#define VERSION_AS_STRING "1.0.0"
#endif
Expand Down

0 comments on commit 6841d70

Please sign in to comment.