decodeIconData static method

IconData? decodeIconData(
  1. dynamic value, {
  2. bool validate = true,
})

Decodes the given value into an IconData. If the value is null then null will be returned.

{
  "codePoint": <int>,
  "fontFamily": <String>,
  "fontPackage": <String>,
  "matchTextDirection": <bool>
}

Implementation

static IconData? decodeIconData(
  dynamic value, {
  bool validate = true,
}) {
  IconData? result;

  if (value is IconData) {
    result = value;
  } else if (value != null) {
    assert(SchemaValidator.validate(
      schemaId: '$_baseSchemaUrl/icon_data',
      value: value,
      validate: validate,
    ));
    result = IconData(
      JsonClass.parseInt(value['codePoint'])!,
      fontFamily: value['fontFamily'],
      fontPackage: value['fontPackage'],
      matchTextDirection: JsonClass.parseBool(value['matchTextDirection']),
    );
  }

  return result;
}