#85: localize on init
This commit is contained in:
@@ -20,6 +20,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
Locale('fr'),
|
Locale('fr'),
|
||||||
Locale('es'),
|
Locale('es'),
|
||||||
Locale('de'),
|
Locale('de'),
|
||||||
|
Locale('pt'),
|
||||||
],
|
],
|
||||||
localizationsDelegates: [
|
localizationsDelegates: [
|
||||||
CountryLocalizations.delegate,
|
CountryLocalizations.delegate,
|
||||||
@@ -44,7 +45,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
comparator: (a, b) => b.name.compareTo(a.name),
|
comparator: (a, b) => b.name.compareTo(a.name),
|
||||||
//Get the country information relevant to the initial selection
|
//Get the country information relevant to the initial selection
|
||||||
onInit: (code) =>
|
onInit: (code) =>
|
||||||
print("on init ${code.name} ${code.dialCode}"),
|
print("on init ${code.name} ${code.dialCode} ${code.name}"),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 400,
|
width: 400,
|
||||||
|
|||||||
@@ -175,6 +175,7 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
|||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
|
|
||||||
this.elements = elements.map((e) => e.localize(context)).toList();
|
this.elements = elements.map((e) => e.localize(context)).toList();
|
||||||
|
_onInit(selectedItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -212,8 +213,6 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
|||||||
selectedItem = elements[0];
|
selectedItem = elements[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
_onInit(selectedItem);
|
|
||||||
|
|
||||||
favoriteElements = elements
|
favoriteElements = elements
|
||||||
.where((e) =>
|
.where((e) =>
|
||||||
widget.favorite.firstWhere(
|
widget.favorite.firstWhere(
|
||||||
|
|||||||
Reference in New Issue
Block a user