So im trying to populate custom values into flutter intl phone field
IntlPhoneField(
readOnly: config.isReadonly,
focusNode: focusNode,
initialCountryCode: 'IN',
countries: allowedCountries,
initialValue: initialValue,
style: context.appTextBold.body3,
dropdownTextStyle: context.appTextBold.body3,
decoration: const InputDecoration(
border: InputBorder.none,
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
errorBorder: InputBorder.none,
focusedErrorBorder: InputBorder.none,
counterText: '',
errorStyle: TextStyle(height: 0),
isDense: true,
// less vertical space, no horizontal padding so dropdown hugs left edge
contentPadding: EdgeInsets.symmetric(vertical: 10),
floatingLabelBehavior: FloatingLabelBehavior.never,
),
dropdownIconPosition:
IconPosition.trailing, // keep icon with country code
disableLengthCheck: true, // ensure no built-in validation errors
validator: (value) => null,
showDropdownIcon: !config.isReadonly,
onChanged: (phone) {
if (onChanged != null) {
onChanged?.call(phone);
}
},
),
Im passing the values from api into the phone field as a list. but this ignore the custom list im passing from api, but when i manually add it as shown below it's accepting the values.
abstract class AllowedCountryList {
static const List<Country> allowedCountryList = [
Country(
name: "India",
nameTranslations: {
"en": "India",
},
flag: "🇮🇳",
code: "IN",
dialCode: "91",
minLength: 10,
maxLength: 10,
)
];
}
Is there something im missing? Is there any reason why api data is getting ignored? I can see the values reaching the phonefield. But this is getting ignored. I also tried with didupdatewidget. How can i solve this. Also intl_phone_field only accept manually hardcoded values?!