map<TResult extends Object?> method

  1. @optionalTypeArgs
TResult map<TResult extends Object?>({
  1. required TResult static(
    1. InputProfilePhotoStatic value
    ),
  2. required TResult animated(
    1. InputProfilePhotoAnimated 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(InputProfilePhotoStatic value) static,
  required TResult Function(InputProfilePhotoAnimated value) animated,
}) {
  final _that = this;
  switch (_that) {
    case InputProfilePhotoStatic():
      return static(_that);
    case InputProfilePhotoAnimated():
      return animated(_that);
  }
}