map<TResult extends Object?> method

  1. @optionalTypeArgs
TResult map<TResult extends Object?>({
  1. required TResult file(
    1. _PlaySourceWithFile value
    ),
  2. required TResult network(
    1. _PlaySourceWithNetwork value
    ),
})

A switch-like method, using callbacks.

Callbacks receives the raw object, upcasted. It is equivalent to doing:

switch (sealedClass) {
  case final Subclass value:
    return ...;
  case final Subclass2 value:
    return ...;
}

Implementation

@optionalTypeArgs
TResult map<TResult extends Object?>({
  required TResult Function(_PlaySourceWithFile value) file,
  required TResult Function(_PlaySourceWithNetwork value) network,
}) {
  final _that = this;
  switch (_that) {
    case _PlaySourceWithFile():
      return file(_that);
    case _PlaySourceWithNetwork():
      return network(_that);
  }
}