September 2019
Beginner
512 pages
12h 52m
English
The next step is to create a class that encapsulates the app's localized values. The AppLocalizations class, for example, would be very similar in all apps, except the string resources involved. This is what it looks like:
// part of app_localization.dartimport 'l10n/messages_all.dart';class AppLocalizations { static Future<AppLocalizations> load(Locale locale) { final String name = locale.countryCode == null ? locale.languageCode : locale.toString(); final String localeName = Intl.canonicalizedLocale(name); return initializeMessages(localeName).then((bool _) { Intl.defaultLocale = localeName; return new AppLocalizations(); }); } static AppLocalizations of(BuildContext context) { return Localizations.of<AppLocalizations>(context, ...Read now
Unlock full access