extract<T> method
Return an Option that conditionally accesses map keys, only if they match the given type.
Useful for accessing nested JSON.
{ 'test': 123 }.extract<int>('test'); /// `Some(123)`
{ 'test': 'string' }.extract<int>('test'); /// `None()`
Implementation
Option<T> extract<T>(K key) {
final value = this[key];
return value is T ? some(value) : const None();
}