keyType<K> abstract method

Class<K>? keyType<K>()
inherited

Retrieves the key type (K) of a map-like or pair-like generic structure.

Common Scenarios

  • Maps: Map<K, V> → returns Class<K>
  • Pairs: Tuple<K, V> → returns Class<K>
  • Non-map classes: returns Class<dynamic> or null

Example

final mapClass = Class.forType<Map<String, int>>();
final keyType = mapClass.asGenericSource().keyType<String>();
print(keyType.getName()); // 'String'

Implementation

Class<K>? keyType<K>();