country_pickers
country_pickers copied to clipboard
Can i precache used flag images?
Can i precache images/flags on app start, like i do with my own assets:
precacheImage(new AssetImage("assets/img/image1.jpg"), context);
precacheImage(new AssetImage("assets/img/image2.jpg"), context);
because when i first come to the screen where i use this country_picker flags/images, the images flashes/loads/pops up, and then after that everything is ok.
Hi @dukaric1991 ! You need to set package field to access the assets(images) of another package as following:
static String getFlagImageAssetPath(String isoCode) {
return "assets/${isoCode.toLowerCase()}.png";
}
static Widget getDefaultFlagImage(Country country) {
return Image.asset(
CountryPickerUtils.getFlagImageAssetPath(country.isoCode),
height: 20.0,
width: 30.0,
fit: BoxFit.fill,
package: "country_pickers",
);
}
You can have a look at here: https://github.com/figengungor/country_pickers/blob/master/lib/utils/utils.dart