unwrapNestedTypes method
Find nested AbstractType.
Implementation
List<AbstractType> unwrapNestedTypes() {
switch (this) {
case final StandardType standardType:
switch (standardType) {
case final ListType listType:
final childType = listType.child;
final nestedTypes = childType.unwrapNestedTypes();
return [listType, childType, ...nestedTypes];
case final MapType mapType:
final keyType = mapType.key;
final valueType = mapType.value;
final nestedKeyTypes = keyType.unwrapNestedTypes();
final nestedValueTypes = valueType.unwrapNestedTypes();
return [
mapType,
keyType,
valueType,
...nestedKeyTypes,
...nestedValueTypes
];
case _:
return [standardType];
}
case final EnumType enumType:
return [enumType];
case final UndeterminedAsDynamic undeterminedAsDynamic:
return [undeterminedAsDynamic];
case final CustomType customType:
final nestedTypes = customType.members
.map((member) => member.type.unwrapNestedTypes())
.expand((type) => type)
.toList();
return [customType, ...nestedTypes];
case NonCanonicalType():
return [const UndeterminedAsDynamic()];
}
}