getTypeName function
Forwards and backwards-compatible method of getting the "name" of type
.
Implementation
String? getTypeName(DartType type) {
var aliasElement = type.alias?.element;
if (aliasElement != null) {
return aliasElement.name;
}
if (type is DynamicType) {
return 'dynamic';
}
if (type is FunctionType) {
return null;
}
if (type is InterfaceType) {
return type.element.name;
}
if (type is VoidType) {
return 'void';
}
throw UnimplementedError('(${type.runtimeType}) $type');
}