diff --git a/example/lib/main.dart b/example/lib/main.dart index 386e592..941e716 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -20,6 +20,7 @@ class _MyAppState extends State { Locale('fr'), Locale('es'), Locale('de'), + Locale('pt'), ], localizationsDelegates: [ CountryLocalizations.delegate, @@ -44,7 +45,7 @@ class _MyAppState extends State { comparator: (a, b) => b.name.compareTo(a.name), //Get the country information relevant to the initial selection onInit: (code) => - print("on init ${code.name} ${code.dialCode}"), + print("on init ${code.name} ${code.dialCode} ${code.name}"), ), SizedBox( width: 400, diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index 2ef13f5..c4de323 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -175,6 +175,7 @@ class CountryCodePickerState extends State { super.didChangeDependencies(); this.elements = elements.map((e) => e.localize(context)).toList(); + _onInit(selectedItem); } @override @@ -212,8 +213,6 @@ class CountryCodePickerState extends State { selectedItem = elements[0]; } - _onInit(selectedItem); - favoriteElements = elements .where((e) => widget.favorite.firstWhere(