Skip to content

Commit deac7b4

Browse files
committed
refactor(app): wrap router content with Scaffold for consistent theming
- Wrap GoRouter content with a Scaffold to provide a consistent background color for areas outside the constrained app width. - Move Card widget inside the Scaffold to create a distinct visual separation between main content and browser background. - Improve theming and layout consistency across different screen sizes.
1 parent 3532d14 commit deac7b4

File tree

1 file changed

+52
-33
lines changed

1 file changed

+52
-33
lines changed

lib/app/view/app.dart

Lines changed: 52 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -206,40 +206,59 @@ class _AppViewState extends State<_AppView> {
206206
fontFamily: fontFamily,
207207
);
208208

209-
return Center(
210-
child: Card(
211-
margin: EdgeInsets.zero, // Remove default card margin
212-
elevation: 4, // Add some elevation to make it "pop"
213-
shape: RoundedRectangleBorder(
214-
borderRadius: BorderRadius.circular(
215-
8,
216-
), // Match cardRadius from theme
217-
),
218-
child: ConstrainedBox(
219-
constraints: const BoxConstraints(
220-
maxWidth: AppConstants.kMaxAppWidth,
209+
return MaterialApp.router(
210+
debugShowCheckedModeBanner: false,
211+
routerConfig: _router,
212+
localizationsDelegates: const [
213+
UiKitLocalizations.delegate,
214+
...AppLocalizations.localizationsDelegates,
215+
],
216+
supportedLocales: UiKitLocalizations.supportedLocales,
217+
theme: baseTheme == AppBaseTheme.dark
218+
? darkThemeData
219+
: lightThemeData,
220+
darkTheme: darkThemeData,
221+
themeMode: switch (baseTheme) {
222+
AppBaseTheme.light => ThemeMode.light,
223+
AppBaseTheme.dark => ThemeMode.dark,
224+
_ => ThemeMode.system,
225+
},
226+
locale: language != null ? Locale(language.code) : null,
227+
// The builder is used to wrap the router's content with a Scaffold
228+
// that provides a distinct background color for the areas outside
229+
// the constrained app width. This ensures a consistent visual
230+
// experience across different screen sizes, clearly separating
231+
// the main application content from the browser's background.
232+
builder: (context, child) {
233+
return Scaffold(
234+
// Use a distinct background color from the theme for the
235+
// areas outside the main constrained content.
236+
backgroundColor:
237+
Theme.of(context).colorScheme.surfaceContainerHighest,
238+
body: Center(
239+
child: Card(
240+
// Remove default card margin to allow it to fill the
241+
// constrained box.
242+
margin: EdgeInsets.zero,
243+
// Add some elevation to make the main content "pop"
244+
// from the background.
245+
elevation: 4,
246+
// Match cardRadius from theme for consistent styling.
247+
shape: RoundedRectangleBorder(
248+
borderRadius: BorderRadius.circular(8),
249+
),
250+
child: ConstrainedBox(
251+
// Constrain the maximum width of the application content.
252+
constraints: const BoxConstraints(
253+
maxWidth: AppConstants.kMaxAppWidth,
254+
),
255+
// The child here is the content provided by the GoRouter.
256+
child: child,
257+
),
258+
),
221259
),
222-
child: MaterialApp.router(
223-
debugShowCheckedModeBanner: false,
224-
routerConfig: _router,
225-
localizationsDelegates: const [
226-
UiKitLocalizations.delegate,
227-
...AppLocalizations.localizationsDelegates,
228-
],
229-
supportedLocales: UiKitLocalizations.supportedLocales,
230-
theme: baseTheme == AppBaseTheme.dark
231-
? darkThemeData
232-
: lightThemeData,
233-
darkTheme: darkThemeData,
234-
themeMode: switch (baseTheme) {
235-
AppBaseTheme.light => ThemeMode.light,
236-
AppBaseTheme.dark => ThemeMode.dark,
237-
_ => ThemeMode.system,
238-
},
239-
locale: language != null ? Locale(language.code) : null,
240-
),
241-
),
242-
),
260+
);
261+
},
243262
);
244263
},
245264
),

0 commit comments

Comments
 (0)