Jesway / flutter_translate

Flutter Translate is a fully featured localization / internationalization (i18n) library for Flutter.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Default locale not set when reopen the app

mohd-aidi opened this issue · comments

HI, this is awesome plugin. but i have an issue for when i set english and malay language but i want to set malay as default language.

but then after select malay as default locale, I close and reopen the app but the default always back to english.

when i changeLocale it works perfectly but it default back to english when i reopen the app.

can you help me?

Widget build(BuildContext context) {
var localizationDelegate = LocalizedApp.of(context).delegate;
return OverlaySupport(
child: MaterialApp(
debugShowCheckedModeBanner: false,
title: translate('app_bar.title'),
localizationsDelegates: [
localizationDelegate
],
locale: Locale(localizationDelegate.currentLocale.languageCode),
theme: ThemeData(
scaffoldBackgroundColor: kBackgroundColor,
primaryColor: kPrimaryColor,
textTheme: Theme.of(context).textTheme.apply(bodyColor: kTextColor),
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: BlocProvider(
create: (context) => AppCubits(),
child: AppCubitLogics(),
)
)
);
}

InkWell(
onTap: (){
print(data);
changeLocale(context, data);
Navigator.pop(context);
},
child: Card(
elevation: 4,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Text(translate('language.name.${data}'), style: TextStyle(fontSize: 22.0),),
),
),
);