When create custom picker flag image can't be accesses
areejmayadeh opened this issue · 4 comments
builder: (CountryCode) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(CountryCode.code),
Image.asset(CountryCode.flagUri),
Icon(Icons.arrow_drop_down)
]);
},
flutter: Another exception was thrown: Unable to load asset: flags/jo.png
hey @areejmayadeh, you could follow steps.
steps:
1- add an image in the flags
file.
2- in pubspec.yaml
file, Click on Pub get
.
3- in country_codes
file, add the name (in the native language of the country) and code and dial_code of a country ...
like this ...
{
"name": "Name of a country in the native language of the country",
"code": "code of a country",
"dial_code": "dial_code of a country",
},
4- in i18n
file > en.josn
file ... add name ( in english language) and code
like this ...
"code of a country": "Name of a country in the English language",
Note :
if you ignore step 4, the name of a country which you add in country_codes
file it will show it, regardless of which language you add it.
thanks @Abdullah-Zakhoi
Hm... I've the same problem as the OP. As far as I understand it, the OP didn't want do add a new country, like the answer describes it. He (and I) simply wanted to know how to access the image of the flag.
I also tried with:
builder: (CountryCode) {
return Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Text(CountryCode.code),
Image.asset(
'package:country_code_picker/' +
CountryCode.flagUri),
Icon(Icons.arrow_drop_down)
]);
},
And get a "Unable to load asset: package:country_code_picker/flags/us.png" error....
OK, found it. It works with:
Image.asset(CountryCode.flagUri, package: 'country_code_picker', width: 30.0,),