handle method

void handle({
  1. required void showAlsoFor(
    1. List<MarkerData> markers, {
    2. required bool disableAnimation,
    }),
  2. required void showOnlyFor(
    1. List<MarkerData> markers, {
    2. required bool disableAnimation,
    }),
  3. required void hideAll({
    1. required bool disableAnimation,
    }),
  4. required void hideOnlyFor(
    1. List<MarkerData> markers, {
    2. required bool disableAnimation,
    }),
  5. required void toggle(
    1. MarkerData marker, {
    2. required bool disableAnimation,
    }),
})

Implementation

void handle({
  required void Function(
    List<MarkerData> markers, {
    required bool disableAnimation,
  })
  showAlsoFor,
  required void Function(
    List<MarkerData> markers, {
    required bool disableAnimation,
  })
  showOnlyFor,
  required void Function({required bool disableAnimation}) hideAll,
  required void Function(
    List<MarkerData> markers, {
    required bool disableAnimation,
  })
  hideOnlyFor,
  required void Function(MarkerData marker, {required bool disableAnimation})
  toggle,
}) {
  final PopupEvent thisEvent = this;
  if (thisEvent is ShowPopupsAlsoFor) {
    return showAlsoFor(
      thisEvent.markers,
      disableAnimation: thisEvent.disableAnimation,
    );
  } else if (thisEvent is ShowPopupsOnlyFor) {
    return showOnlyFor(
      thisEvent.markers,
      disableAnimation: thisEvent.disableAnimation,
    );
  } else if (thisEvent is HideAllPopupsEvent) {
    return hideAll(disableAnimation: thisEvent.disableAnimation);
  } else if (thisEvent is HidePopupsOnlyFor) {
    return hideOnlyFor(
      thisEvent.markers,
      disableAnimation: thisEvent.disableAnimation,
    );
  } else if (thisEvent is TogglePopupEvent) {
    return toggle(
      thisEvent.marker,
      disableAnimation: thisEvent.disableAnimation,
    );
  } else {
    throw 'Unknown PopupEvent type: ${thisEvent.runtimeType}';
  }
}