handleTapDown method Null safety

  1. @protected
  2. @override
void handleTapDown(
  1. {required PointerDownEvent down}
)
protected">@protectedoverride

A pointer has contacted the screen, which might be the start of a tap.

This triggers after the down event, once a short timeout (deadline) has elapsed, or once the gesture has won the arena, whichever comes first.

The parameter down is the down event of the primary pointer that started the tap sequence.

If this recognizer doesn't win the arena, handleTapCancel is called next. Otherwise, handleTapUp is called next.

Implementation

@protected
@override
void handleTapDown({required PointerDownEvent down}) {
  final TapDownDetails details = TapDownDetails(
    globalPosition: down.position,
    localPosition: down.localPosition,
    kind: getKindForPointer(down.pointer),
  );
  switch (down.buttons) {
    case kPrimaryButton:
      if (onTapDown != null) {
        invokeCallback<void>('onTapDown', () => onTapDown!(details));
      }
      break;
    case kSecondaryButton:
      if (onSecondaryTapDown != null) {
        invokeCallback<void>('onSecondaryTapDown', () => onSecondaryTapDown!(details));
      }
      break;
    case kTertiaryButton:
      if (onTertiaryTapDown != null) {
        invokeCallback<void>('onTertiaryTapDown', () => onTertiaryTapDown!(details));
      }
      break;
    default:
  }
}