when method

void when({
  1. required void onManoeuvreBalloon(
    1. ManoeuvreBalloon value
    ),
  2. required void onManoeuvreWithLaneSignBalloon(
    1. ManoeuvreWithLaneSignBalloon value
    ),
  3. required void onLaneSignBalloon(
    1. LaneSignBalloon value
    ),
  4. required void onRouteSummaryBalloon(
    1. RouteSummaryBalloon value
    ),
  5. required void onAlternativeBalloon(
    1. AlternativeBalloon value
    ),
})

Applies the passed function to the variant value.

Implementation

void when({
  required void Function(ManoeuvreBalloon value) onManoeuvreBalloon,
  required void Function(ManoeuvreWithLaneSignBalloon value)
      onManoeuvreWithLaneSignBalloon,
  required void Function(LaneSignBalloon value) onLaneSignBalloon,
  required void Function(RouteSummaryBalloon value) onRouteSummaryBalloon,
  required void Function(AlternativeBalloon value) onAlternativeBalloon,
}) {
  if (_value is ManoeuvreBalloon) {
    return onManoeuvreBalloon(_value as ManoeuvreBalloon);
  }
  if (_value is ManoeuvreWithLaneSignBalloon) {
    return onManoeuvreWithLaneSignBalloon(
        _value as ManoeuvreWithLaneSignBalloon);
  }
  if (_value is LaneSignBalloon) {
    return onLaneSignBalloon(_value as LaneSignBalloon);
  }
  if (_value is RouteSummaryBalloon) {
    return onRouteSummaryBalloon(_value as RouteSummaryBalloon);
  }
  if (_value is AlternativeBalloon) {
    return onAlternativeBalloon(_value as AlternativeBalloon);
  }
  assert(false);
}