Skip to content

Instantly share code, notes, and snippets.

@rohan20
Last active September 4, 2018 11:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rohan20/c0baaa670278da082a66737a4ac5d57e to your computer and use it in GitHub Desktop.
Save rohan20/c0baaa670278da082a66737a4ac5d57e to your computer and use it in GitHub Desktop.
flutter-localizations
import 'dart:async';
import 'package:flutter/material.dart';
import '../localization/app_translations.dart';
class AppTranslationsDelegate extends LocalizationsDelegate<AppTranslations> {
final Locale newLocale;
const AppTranslationsDelegate({this.newLocale});
@override
bool isSupported(Locale locale) {
return ["en", "es"].contains(locale.languageCode);
}
@override
Future<AppTranslations> load(Locale locale) {
return AppTranslations.load(newLocale ?? locale);
}
@override
bool shouldReload(LocalizationsDelegate<AppTranslations> old) {
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment