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