I am using a button in drawer to change lange from arabic to english,
here is the code onTap ,
onTap: () {
if (EasyLocalization.of(context)
.locale
.languageCode ==
'ar') {
EasyLocalization.of(context).locale =
Locale('en');
} else {
EasyLocalization.of(context).locale =
Locale('ar');
}
Navigator.pop(context);
}
why it need to hot reload app to apply changes
@fatimahossny this #116 resolve ur issues
It works fine except that it needs to rebuild the app after change language, I found this solution to rebuild app after changing language by calling this method in language button .
void rebuildAllChildren(BuildContext context) {
void rebuild(Element el) {
el.markNeedsBuild();
el.visitChildren(rebuild);
}
(context as Element).visitChildren(rebuild);
}
next version don't need do
void rebuildAllChildren(BuildContext context) {
void rebuild(Element el) {
el.markNeedsBuild();
el.visitChildren(rebuild);
}
(context as Element).visitChildren(rebuild);
}
just like this code will be work well
onPressed: () {
EasyLocalization.of(context).locale.languageCode !='ar'
? EasyLocalization.of(context).locale = EasyLocalization.of(context).supportedLocales[1]
: EasyLocalization.of(context).locale =EasyLocalization.of(context).supportedLocales[0];
},
@aissat Still some data is not translated
Most helpful comment
It works fine except that it needs to rebuild the app after change language, I found this solution to rebuild app after changing language by calling this method in language button .