extractMap method

Option<Map<K, dynamic>> extractMap(
  1. K key
)

Return an Option that conditionally accesses map keys, if they contain a map with the same key type. Useful for accessing nested JSON.

expect(
  { 'test': { 'foo': 'bar' } }.extractMap('test'),
  Option.of({ 'foo': 'bar' }),
);
expect(
  { 'test': 'string' }.extractMap('test'),
  Option.none(),
);

Implementation

Option<Map<K, dynamic>> extractMap(K key) => extract<Map<K, dynamic>>(key);