fromData method
Recreates an object from the given data representation.
If the value
is not of the expected type, this must throw an
UnexpectedTypeException.
Implementation
@override
T fromData(Object value) {
if (value is! String) {
throw UnexpectedTypeException(value: value, expectedTypes: [String]);
}
for (final enumValue in values) {
if (enumValue.name == value) {
return enumValue;
}
}
throw ArgumentError.value(value, 'value', 'not a valid enum name for $T');
}