getAssetPathFromCode static method
Generates the asset path for a flag SVG from a FlagsCode enum.
countryCode
The FlagsCode enum value
flagSize
The flag size/aspect ratio (defaults to 4x3)
Returns the asset path string that can be used with AssetImage or SvgPicture.asset
Example:
String assetPath = Flag.getAssetPathFromCode(FlagsCode.US);
// Returns: 'packages/flag/res/4x3/us.svg'
String squareAssetPath = Flag.getAssetPathFromCode(FlagsCode.US, flagSize: FlagSize.size_1x1);
// Returns: 'packages/flag/res/1x1/us.svg'
Implementation
static String getAssetPathFromCode(FlagsCode countryCode,
{FlagSize flagSize = FlagSize.size_4x3}) {
String countryName =
EnumToString.convertToString(countryCode).toLowerCase();
return getAssetPath(countryName, flagSize: flagSize);
}