typeArgumentOf function
Returns the bound DartType
from the instance object
.
For example for the following code:
const foo = const <String>[];
const bar = const ['A string'];
... both foo
and bar
should return the DartType
for String
.
Implementation
DartType typeArgumentOf(DartObject object, [int index = 0]) {
var type = object.type;
if (type is ParameterizedType) {
var typeArguments = type.typeArguments;
if (typeArguments.isNotEmpty) {
return type.typeArguments[index];
}
}
return DynamicTypeImpl.instance;
}