flagForUf function

FlagArtwork? flagForUf(
  1. String uf, {
  2. FlagStyle style = FlagStyle.circle,
})

Returns the flag for uf, or null when the code is not recognised.

uf is case insensitive and surrounding whitespace is ignored, so values straight out of a text field work without cleaning them up first.

Implementation

FlagArtwork? flagForUf(String uf, {FlagStyle style = FlagStyle.circle}) {
  final key = uf.trim().toUpperCase();
  return switch (style) {
    FlagStyle.full => fullByUf[key],
    FlagStyle.rounded => roundedByUf[key],
    FlagStyle.squareRounded => squareRoundedByUf[key],
    FlagStyle.circle => circleByUf[key],
  };
}