findKeyType<K> abstract method

Class<K>? findKeyType<K>(
  1. Class parentClass,
  2. Type? key
)

Finds the key type of a map-like class.

Type Parameters:

  • K: The expected key type.

Parameters:

  • parentClass: The class representing the map.
  • key: The runtime Type to help narrow the match (optional).

Returns:

  • A Class<K> representing the key type, or null if none exists.

Example

final mapClass = await loader.loadClass<Map<String, int>>('dart:core/map.dart.Map');
final stringType = loader.findKeyType<String>(mapClass);
print(stringType?.qualifiedName); // "dart:core/string.dart.String"

Implementation

Class<K>? findKeyType<K>(Class parentClass, Type? key);