@@ -10,6 +10,7 @@ class CountryDropdown extends StatefulWidget {
1010 final CountryItemBuilder ? listItemBuilder;
1111 final bool printCountryName;
1212 final String ? initialPhoneCode;
13+ final List <PhoneCountryData >? countryItems;
1314 final ValueChanged <PhoneCountryData > onCountrySelected;
1415
1516 final int elevation;
@@ -44,6 +45,7 @@ class CountryDropdown extends StatefulWidget {
4445 this .listItemBuilder,
4546 this .printCountryName = false ,
4647 this .initialPhoneCode,
48+ this .countryItems,
4749 required this .onCountrySelected,
4850 this .elevation = 8 ,
4951 this .style,
@@ -82,12 +84,18 @@ class _CountryDropdownState extends State<CountryDropdown> {
8284 }
8385
8486 PhoneCountryData get _initialValue {
87+ final items = _countryItems;
88+
8589 if (widget.initialPhoneCode != null ) {
86- return PhoneCodes . getAllCountryDatas (). firstWhereOrNull ((c) =>
87- c.phoneCode == widget.initialPhoneCode) ??
88- PhoneCodes . getAllCountryDatas () .first;
90+ return items. firstWhereOrNull (
91+ (c) => c.phoneCode == widget.initialPhoneCode) ??
92+ items .first;
8993 }
90- return PhoneCodes .getAllCountryDatas ().first;
94+ return items.first;
95+ }
96+
97+ List <PhoneCountryData > get _countryItems {
98+ return widget.countryItems ?? PhoneCodes .getAllCountryDatas ();
9199 }
92100
93101 Widget _buildSelectedLabel (
@@ -177,7 +185,7 @@ class _CountryDropdownState extends State<CountryDropdown> {
177185 elevation: widget.elevation,
178186 itemHeight: widget.itemHeight,
179187 selectedItemBuilder: (c) {
180- return PhoneCodes . getAllCountryDatas ()
188+ return _countryItems
181189 .map (
182190 (e) => DropdownMenuItem <PhoneCountryData >(
183191 child: _buildSelectedLabel (e),
@@ -186,7 +194,7 @@ class _CountryDropdownState extends State<CountryDropdown> {
186194 )
187195 .toList ();
188196 },
189- items: PhoneCodes . getAllCountryDatas ()
197+ items: _countryItems
190198 .map (
191199 (e) => DropdownMenuItem <PhoneCountryData >(
192200 child: _buildListLabel (e),
0 commit comments