getTypeInterface method
Get a set of encoders/decoders for specific type. Mainly used to define custom type de/serialization logic.
Implementation
TypeInterface getTypeInterface(String type) {
var typeInterface = types[type];
// Special case - string means an alias.
// Goes through the alias chain and tracks recursion.
if (typeInterface is String) {
List<String> chain = [];
while (typeInterface is String) {
if (chain.contains(typeInterface)) {
throw ArgumentError(
'Recursive definition found: ${chain.join(
" -> "
)} -> $typeInterface'
);
}
chain.add(typeInterface);
typeInterface = types[typeInterface];
}
}
if (typeInterface == null) {
throw ArgumentError("Type $type is not registered");
}
return typeInterface;
}