Skip to content

Instantly share code, notes, and snippets.

@tianhaoz95
Created March 19, 2020 05:35
Show Gist options
  • Save tianhaoz95/43df1ee4930a9d4af79d1e2cd2a6f55f to your computer and use it in GitHub Desktop.
Save tianhaoz95/43df1ee4930a9d4af79d1e2cd2a6f55f to your computer and use it in GitHub Desktop.
example app with i18n
class PhotoChatApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider<AppContext>(
create: (context) =>
AppContext(appRunningStateOverride: this.appRunningState),
child: MaterialApp(
title: 'Mini Donkey',
localizationsDelegates: [
AppLocalizationsDelegate(),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
localeResolutionCallback:
(Locale locale, Iterable<Locale> supportedLocales) {
print('checking ' + locale.toString());
return locale;
},
supportedLocales: [
const Locale('en'),
const Locale.fromSubtags(languageCode: 'zh'),
],
));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment