@@ -9,7 +9,7 @@ class CountryDropdown extends StatefulWidget {
9
9
final CountryItemBuilder ? selectedItemBuilder;
10
10
final CountryItemBuilder ? listItemBuilder;
11
11
final bool printCountryName;
12
- final String ? initialPhoneCode ;
12
+ final PhoneCountryData ? initialCountryData ;
13
13
final List <PhoneCountryData >? filter;
14
14
final ValueChanged <PhoneCountryData > onCountrySelected;
15
15
@@ -34,7 +34,7 @@ class CountryDropdown extends StatefulWidget {
34
34
35
35
/// [filter] if you need a predefined list of countries only,
36
36
/// pass it here
37
- /// [initialPhoneCode] a phone code of the country without leading +
37
+ /// [initialCountryData] initial country data to be selected
38
38
/// [selectedItemBuilder] use this if you want to make
39
39
/// the selected item look the way you want
40
40
/// [listItemBuilder] the same as [selectedItemBuilder] but
@@ -50,7 +50,7 @@ class CountryDropdown extends StatefulWidget {
50
50
this .selectedItemBuilder,
51
51
this .listItemBuilder,
52
52
this .printCountryName = false ,
53
- this .initialPhoneCode ,
53
+ this .initialCountryData ,
54
54
this .triggerOnCountrySelectedInitially = true ,
55
55
this .filter,
56
56
required this .onCountrySelected,
@@ -84,9 +84,9 @@ class _CountryDropdownState extends State<CountryDropdown> {
84
84
@override
85
85
void initState () {
86
86
_countryItems = widget.filter ?? PhoneCodes .getAllCountryDatas ();
87
- if (widget.initialPhoneCode != null ) {
88
- _initialValue = _countryItems. firstWhereOrNull (
89
- ( c) => c.phoneCode == widget.initialPhoneCode ) ??
87
+ if (widget.initialCountryData != null ) {
88
+ _initialValue = _countryItems
89
+ . firstWhereOrNull (( c) => c == widget.initialCountryData ) ??
90
90
_countryItems.first;
91
91
}
92
92
if (widget.triggerOnCountrySelectedInitially && _initialValue != null ) {
0 commit comments