Home > Software engineering >  Easy Localization Flutter package
Easy Localization Flutter package

Time:01-11

I use the easy localization package, how can I check and change the language with just one button?

https://pub.dev/packages/easy_localization

TextButton(
  onPressed: () {
    // 'En' 
    // 'Ar'
  },
  child: Text('Switch lang'),
)

CodePudding user response:

You need to have JSON file for changing the language. if so, simply you need to take the language by calling EasyLocalization.of(context)?.locale; or after importing EasyLocalization package just write context.locale;

For changing use EasyLocalization.of(context)?.setLocale(Locale('EN')); or context.setLocale(Locale('EN'));

  • Related