match<T> method

T match<T>({
  1. required T fromAsset(
    1. KeyFromAsset value
    ),
  2. required T fromFile(
    1. KeyFromFile value
    ),
  3. required T fromString(
    1. KeyFromString value
    ),
})

Implementation

T match<T>({
  required T Function(KeyFromAsset value) fromAsset,
  required T Function(KeyFromFile value) fromFile,
  required T Function(KeyFromString value) fromString,
}) {
  return switch (this._index) {
    0 => fromAsset(this._value as KeyFromAsset),
    1 => fromFile(this._value as KeyFromFile),
    2 => fromString(this._value as KeyFromString),
    _ => throw NativeException("Unrecognized case index ${this._index}")
  };
}