I am working with a flutter project and there is a dropdown menu that shows all the countries as a default. It shows Afghanistan, but I want to show India as default:
CountryPickerDropdown(
onTap: () =>
FocusScope.of(context)
.requestFocus(
FocusNode()),
onValuePicked: (
Country country) {
print("${country.name}");
},
itemBuilder: (Country country) {
return Row(
children: <Widget>[
CountryPickerUtils
.getDefaultFlagImage(
country),
Expanded(
child: Text(
country.isoCode,
),
),
],
);
},
itemHeight: null,
isExpanded: true,
icon: SizedBox(),
)
Does anyone know how to do it? Thanks in advance
try below code hope its helpful to you. just Set initialValue
used country_pickers
package here
Your Widget:
CountryPickerDropdown(
initialValue: 'in',
itemBuilder: _buildDropdownItem,
onValuePicked: (Country country) {
print("${country.name}");
},
),
Your method:
Widget _buildDropdownItem(Country country) => Container(
child: Row(
children: <Widget>[
CountryPickerUtils.getDefaultFlagImage(country),
SizedBox(
width: 8.0,
),
Text("+${country.phoneCode}(${country.isoCode})"),
],
),
);