use didchangedependencies

This commit is contained in:
Salvatore Giordano
2020-04-07 14:41:30 +02:00
parent 7ade439518
commit 81c668ed43
2 changed files with 9 additions and 4 deletions

View File

@@ -43,7 +43,8 @@ class _MyAppState extends State<MyApp> {
showFlagDialog: true,
comparator: (a, b) => b.name.compareTo(a.name),
//Get the country information relevant to the initial selection
onInit: (code) => print("${code.name} ${code.dialCode}"),
onInit: (code) =>
print("on init ${code.name} ${code.dialCode}"),
),
SizedBox(
width: 400,

View File

@@ -163,11 +163,15 @@ class CountryCodePickerState extends State<CountryCodePicker> {
}
@override
void didUpdateWidget(CountryCodePicker oldWidget) {
super.didUpdateWidget(oldWidget);
void didChangeDependencies() {
super.didChangeDependencies();
this.elements = elements.map((e) => e.localize(context)).toList();
_onInit(selectedItem);
}
@override
void didUpdateWidget(CountryCodePicker oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.initialSelection != widget.initialSelection) {
if (widget.initialSelection != null) {