from method
Returns an Enum instance by o
.
Implementation
O? from(Object? o) {
if (o == null) {
return null;
} else if (o is O) {
return o as O;
}
var s = o.toString().trim();
if (s.startsWith('"') || s.startsWith("'")) {
s = s.substring(1).trim();
}
if (s.endsWith('"') || s.endsWith("'")) {
s = s.substring(0, s.length - 1).trim();
}
var obj = valuesByName[s];
if (obj != null) {
return obj;
}
for (var e in valuesByName.entries) {
var name = e.key;
if (equalsIgnoreAsciiCase(name, s)) {
return e.value;
}
}
return null;
}