when<T> method

T? when<T>({
  1. T? instantaneous(
    1. InstantaneousTileDisplay instantaneous
    )?,
  2. T? fadeIn(
    1. FadeInTileDisplay fadeIn
    )?,
})

Output a value of type T dependent on this and its type

Implementation

T? when<T>({
  T? Function(InstantaneousTileDisplay instantaneous)? instantaneous,
  T? Function(FadeInTileDisplay fadeIn)? fadeIn,
}) {
  final display = this;
  return switch (display) {
    InstantaneousTileDisplay() => instantaneous?.call(display),
    FadeInTileDisplay() => fadeIn?.call(display),
  };
}