Created
April 5, 2019 15:01
-
-
Save Jonathanlight/5c7bf54a09495e2d261d1110d1552c49 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyHomeState extends State<MyHomePage> { | |
Locale currentLang; | |
int clicked = 0; | |
@override | |
void initState() { | |
super.initState(); | |
new Future.delayed(Duration.zero, () async { | |
await FlutterI18n.refresh(context, new Locale('fr')); | |
setState(() { | |
currentLang = FlutterI18n.currentLocale(context); | |
}); | |
}); | |
} | |
changeLanguage() { | |
setState(() { | |
currentLang = currentLang.languageCode == 'fr' | |
? new Locale('en') | |
: new Locale('es'); | |
}); | |
} | |
language(String lang) { | |
setState(() { | |
new Future.delayed(Duration.zero, () async { | |
await FlutterI18n.refresh(context, new Locale(lang)); | |
setState(() { | |
currentLang = FlutterI18n.currentLocale(context); | |
}); | |
}); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment