localization_delegate.dart 801 Bytes
Newer Older
1 2 3
import 'package:flutter/cupertino.dart';
import 'package:logair_application/localization/localization.dart';

4
/// Enables the loading and reloading of app [Locale]s
5 6
class AppLocalizationDelegate extends LocalizationsDelegate<AppLocalization> {
  const AppLocalizationDelegate();
7

8
  /// Returns whether the demanded locale exists in the app's localization files
9
  @override
10 11 12 13
  bool isSupported(Locale locale) => [
    'en',
    'fr'
  ].contains(locale.languageCode);
14

15
  /// Delegates the loading of [Locale] to an async task, which enables it to be done in the background.
16
  @override
17
  Future<AppLocalization> load(Locale locale) => AppLocalization.load(locale);
18

19
  /// Returns whether the app should reload
20
  @override
21
  bool shouldReload(AppLocalizationDelegate old) => false;
22
}