Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
const _supportedLocales = ['en', 'fr', 'ru'];
class ExampleLocalizations {
final Translations translations;
const ExampleLocalizations(this.translations);
static final _translations = <String, Translations Function()>{
'en': () => const Translations(),
'fr': () => const Translations_fr(),
'ru': () => const Translations_ru(),
static const LocalizationsDelegate<ExampleLocalizations> delegate =
static final List<Locale> supportedLocales = => Locale(x)).toList();
static Future<ExampleLocalizations> load(Locale locale) =>
static Translations of(BuildContext context) =>
Localizations.of<ExampleLocalizations>(context, ExampleLocalizations)
class _ExampleLocalizationsDelegate
extends LocalizationsDelegate<ExampleLocalizations> {
const _ExampleLocalizationsDelegate();
bool isSupported(Locale locale) =>
Future<ExampleLocalizations> load(Locale locale) =>
bool shouldReload(LocalizationsDelegate<ExampleLocalizations> old) => false;

This comment has been minimized.

Copy link

@BeliliFahem BeliliFahem commented Sep 7, 2020

I have the following complication error:
error: The return type 'Translations_fr' isn't a 'Translations', as required by the closure's context. (return_of_invalid_type_from_closure at ... )


This comment has been minimized.

Copy link
Owner Author

@foxanna foxanna commented Sep 16, 2020

Do you have any error for Translations_ru class? If not, maybe you have a different .yaml file name for French?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment