fromKeyValue static method
Creates an attribute instance from a key-value pair.
This is primarily used for deserialization and allows creating attribute instances from stored data.
Returns null if no attribute is found for the given key.
Example:
final attribute = EasyAttribute.fromKeyValue('bold', true);
Implementation
static EasyAttribute? fromKeyValue(
String key,
dynamic value, {
bool acceptUnknown = true,
}) {
EasyAttribute<Object?>? origin = _registry[key] ??
_customAttributes[key] ??
alternativeNames[key] ??
alternativeNames[value];
if (acceptUnknown && origin == null) {
origin = UnknownAttribute(key: key, value: value);
}
if (origin == null) return null;
final EasyAttribute<Object?> attribute = origin.clone(value);
return attribute;
}