runtimeTypeValue property
Object
get
runtimeTypeValue
What the script's runtimeType answers. ghissues72: an instance
created with type arguments answers with them, Box<int> as Dart prints
it, equal to another instance's of the same class and arguments only
(InterpretedGenericType). A non-generic instance, and one whose
arguments are the class's defaults (Box(), which the interpreter
fills with dynamic, or a parameter's bound), answers with its class,
as before: in Dart the literal Box denotes exactly that type, so
Box().runtimeType == Box holds. It prints Box where Dart prints
Box<dynamic>.
Implementation
Object get runtimeTypeValue {
final arguments = typeArguments;
if (arguments == null || arguments.isEmpty) return klass;
final names = klass.typeParameterNames;
var defaults = arguments.length == names.length;
for (var i = 0; defaults && i < names.length; i++) {
// Omitted arguments arrive as `dynamic`, bounded or not.
final name = arguments[i].name;
defaults =
name == 'dynamic' ||
name == klass.typeParameterBounds[names[i]]?.name;
}
return defaults ? klass : InterpretedGenericType(klass, arguments);
}