I am a beginner in flutter, I am working on existing code.
I use the intl_phone_field package | Flutter Package to validate a phone number depending on the country.
However, the console shows me this error:
The argument type
List<String>
can’t be assigned to the parameter typeList<Country>?
.
I’ll give you an image capture. Please guide me
How do I correct this error? I’ve been struggling for 1 week
3
Answers
image capture
Try this
create this method above the build context
then call inside the build context like this
then use the
selectedCountries
incountries:
eg.
Hope this helps!!
The countries property of IntlPhoneField get a list of Country with the possibility for values to be null (List< Country >?), by providing e.code you’re assigning a String instead of a Country.
I assume that countries is a List of country, instead of e.code you should just put e
I can see that you want to exclude Armenia which has code "AM" so instead of putting an empty String, you can just put null.
To fix that, you should replace that part with: