Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save shafayathossain/c4e74986f01677a7d81df8882f5af2fc to your computer and use it in GitHub Desktop.

Select an option

Save shafayathossain/c4e74986f01677a7d81df8882f5af2fc to your computer and use it in GitHub Desktop.
Widget materialAppWrapper(Widget child) {
return Builder( // <-- Wrap with Builder
builder: (context) {
final locale = Localizations.maybeLocaleOf(context); // <-- Access localizations
return MaterialApp(
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
darkTheme: ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.deepPurple,
brightness: Brightness.dark,
),
useMaterial3: true,
),
locale: locale,
supportedLocales: AppLocalizations.supportedLocales,
localizationsDelegates: const [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
home: Scaffold(
body: child,
),
);
},
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment