getFlag method
Get flag for this widget
Implementation
Widget? getFlag() {
final locCode = localeNameFlag?.name ?? langCode ?? '??';
final lang = languageToCountry[locCode] ??
<String>[locCode, 'Unknown language code: $locCode'];
var flag = child;
if (useEmoji && locCode != systemLocale) {
final emoji = localeNameFlag?.locale?.emoji;
flag ??= (emoji != null)
? SizedBox(height: radius, child: FittedBox(child: Text(emoji)))
: null;
}
flag ??= localeNameFlag?.flag != null
? CircleFlag(
shape: shape, size: radius ?? 48, child: localeNameFlag?.flag!)
: null;
flag ??= Flags.instance[(lang[0]).toLowerCase()] != null
? CircleFlag(
shape: shape,
size: radius ?? 48,
child: Flags.instance[(lang[0]).toLowerCase()]!.svg)
: null;
if (flag == null || useNLettersInsteadOfIcon > 0) {
flag = child ??
Padding(
padding: const EdgeInsets.all(2.0),
child: FittedBox(
child: Text(
(countriesWithMulti.containsKey(locCode))
? locCode.split('_').first.toUpperCase()
: locCode.split('_').last.toUpperCase(),
semanticsLabel: localeNameFlag?.language ?? lang[1],
)),
);
}
return flag;
}