keyType<K> abstract method
Retrieves the key type (K) of a map-like or pair-like generic structure.
Common Scenarios
- Maps:
Map<K, V>→ returnsClass<K> - Pairs:
Tuple<K, V>→ returnsClass<K> - Non-map classes: returns
Class<dynamic>ornull
Example
final mapClass = Class.forType<Map<String, int>>();
final keyType = mapClass.asGenericSource().keyType<String>();
print(keyType.getName()); // 'String'
Implementation
Class<K>? keyType<K>();