match

R match<R>({

  1. required R some(
    1. T
    ),
  2. required R none(),
})

Pattern match on nullable value with cases for non-null and null.

Implementation

R match<R>({required R Function(T) some, required R Function() none}) =>
    switch (this) {
      final T value => some(value),
      null => none(),
    };