Flags
Flags
The package includes 256 SVG country flags, minified and embedded as strings. Flags are keyed by ISO 3166-1 alpha-2 country codes.
SVG Flags
Get a Flag by Country Code
GoDartTypeScriptphp
import { getFlag, flags } from 'infobits-intl';
// Using the lookup function
const svg = getFlag('US');
// Or access the map directly
const svgDirect = flags['US'];Rendering SVG Flags
The SVG strings can be used directly in your application:
GoDartTypeScriptphp
import { getFlag } from 'infobits-intl';
// In a web application
const svg = getFlag('NO');
if (svg) {
document.getElementById('flag-container')!.innerHTML = svg;
}Emoji Flags
Emoji flags are generated from country codes using regional indicator symbols.
GoDartTypeScriptphp
import { getEmojiFlag } from 'infobits-intl';
console.log(getEmojiFlag('US'));
console.log(getEmojiFlag('NO'));Language Flags
Languages can have a representative flag via their defaultFlagCode.
GoDartTypeScriptphp
import { getLanguageByCode, getFlag } from 'infobits-intl';
const lang = getLanguageByCode('fr');
if (lang?.defaultFlagCode) {
const svg = getFlag(lang.defaultFlagCode);
}All Available Flags
Iterate over all available flags:
GoDartTypeScriptphp
import { flags } from 'infobits-intl';
for (const [code, svg] of Object.entries(flags)) {
console.log(`${code}: ${svg.length} bytes`);
}