decodeSemanticsTag static method

SemanticsTag? decodeSemanticsTag(
  1. dynamic value, {
  2. bool validate = false,
})

Decodes the given value to an SemanticsTag. This expects the given value to be of the following structure:

{
  "name": <String>
}

Implementation

static SemanticsTag? decodeSemanticsTag(
  dynamic value, {
  bool validate = false,
}) {
  SemanticsTag? result;

  if (value is SemanticsTag) {
    result = value;
  } else if (value != null) {
    assert(SchemaValidator.validate(
      schemaId: '$_baseSchemaUrl/semantics_tag',
      value: value,
      validate: validate,
    ));

    result = SemanticsTag(value['name']);
  }

  return result;
}