Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

When create custom picker flag image can't be accesses #86

Closed
areejmayadeh opened this issue Jun 5, 2020 · 4 comments
Closed

When create custom picker flag image can't be accesses #86

areejmayadeh opened this issue Jun 5, 2020 · 4 comments

Comments

@areejmayadeh
Copy link

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

@abdullah-khudher
Copy link
Contributor

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.

@imtoori
Copy link
Owner

imtoori commented Sep 19, 2020

thanks @Abdullah-Zakhoi

@imtoori imtoori closed this as completed Sep 19, 2020
@akreienbring
Copy link

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....

@akreienbring
Copy link

OK, found it. It works with:

Image.asset(CountryCode.flagUri, package: 'country_code_picker', width: 30.0,),

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants