localizationsDelegates property

Iterable<LocalizationsDelegate> localizationsDelegates

The delegates for this app's Localizations widget.

The delegates collectively define all of the localized resources for this application's Localizations widget.

Delegates that produce WidgetsLocalizations and MaterialLocalizations are included automatically. Apps can provide their own versions of these localizations by creating implementations of LocalizationsDelegate or LocalizationsDelegate whose load methods return custom versions of WidgetsLocalizations or MaterialLocalizations.

For example: to add support to MaterialLocalizations for a locale it doesn't already support, say const Locale('foo', 'BR'), one could just extend DefaultMaterialLocalizations:

class FooLocalizations extends DefaultMaterialLocalizations {
  FooLocalizations(Locale locale) : super(locale);
  String get okButtonLabel {
    if (locale == const Locale('foo', 'BR'))
      return 'foo';
    return super.okButtonLabel;

A FooLocalizationsDelegate is essentially just a method that constructs a FooLocalizations object. We return a SynchronousFuture here because no asynchronous work takes place upon "loading" the localizations object.

class FooLocalizationsDelegate extends LocalizationsDelegate<MaterialLocalizations> {
  const FooLocalizationsDelegate();
  Future<FooLocalizations> load(Locale locale) {
    return new SynchronousFuture(new FooLocalizations(locale));
  bool shouldReload(FooLocalizationsDelegate old) => false;

Constructing a MaterialApp with a FooLocalizationsDelegate overrides the automatically included delegate for MaterialLocalizations because only the first delegate of each LocalizationsDelegate.type is used and the automatically included delegates are added to the end of the app's localizationsDelegates list.

new MaterialApp(
  localizationsDelegates: [
    const FooLocalizationsDelegate(),
  // ...


final Iterable<LocalizationsDelegate<dynamic>> localizationsDelegates