resolveGeneric method

Class? resolveGeneric([
  1. List<int>? indexes
])

Convenience method that resolves a specific generic parameter to a Class.

This method gets a specific generic parameter using the provided indexes and resolves it to a Class instance.

Parameters:

  • indexes: Optional list of indexes to navigate nested generics

Returns:

  • Class instance representing the resolved generic parameter
  • null if the generic parameter cannot be resolved or doesn't exist

Example:

final mapType = ResolvableType.forClass(Map<String, List<int>>);

final keyClass = mapType.resolveGeneric([0]); // String
final valueClass = mapType.resolveGeneric([1]); // List<int>

print(keyClass?.getType()); // String
print(valueClass?.getType()); // List<int>

// For nested access, you'd need to chain calls
final valueType = mapType.getGeneric([1]); // ResolvableType for List<int>
final elementClass = valueType.resolveGeneric([0]); // int
print(elementClass?.getType()); // int

Implementation

Class? resolveGeneric([List<int>? indexes]) {
  return getGeneric(indexes).resolve();
}