decodeIconFont static method

HWIconFont? decodeIconFont(
  1. DartObject? obj
)

The font a Flutter IconData constant draws its glyph out of, or null when obj is not one.

An icon without a family is not renderable on its own — nothing says which file the glyph lives in — so it decodes as null rather than as a font named after nothing.

Implementation

static HWIconFont? decodeIconFont(DartObject? obj) {
  if (obj == null || obj.isNull) return null;
  final family = getField(obj, 'fontFamily')?.toStringValue();
  if (family == null || family.isEmpty) return null;
  final package = getField(obj, 'fontPackage')?.toStringValue();
  return HWIconFont(
    family: family,
    package: package == null || package.isEmpty ? null : package,
  );
}