TouchRipple constructor

const TouchRipple({
  1. Key? key,
  2. required Widget child,
  3. Clip clipBehavior = Clip.hardEdge,
  4. BorderRadius borderRadius = BorderRadius.zero,
  5. BorderRadius rippleRadius = BorderRadius.zero,
  6. SystemMouseCursor? cursor,
  7. DoubleTapBehavior doubleTapBehavior = DoubleTapBehavior.cancel,
  8. LongPressBehavior longPressBehavior = LongPressBehavior.cancel,
  9. RippleOverlapBehavior overlapBehavior = RippleOverlapBehavior.cancel,
  10. RippleOverlapBehavior? tapOverlapBehavior,
  11. RippleOverlapBehavior? doubleTapOverlapBehavior,
  12. StartTapRippleEffect startTapEffect = StartTapRippleEffect.pointerDown,
  13. double touchSlop = kTouchSlop,
  14. bool isActive = true,
  15. StartOnEvent startOnTap = const StartOnEvent(isWait: false),
  16. StartOnEvent startOnDoubleTap = const StartOnEvent(isWait: false),
  17. double durationScale = 1,
  18. Color rippleColor = const Color.fromRGBO(0, 0, 0, 0.4),
  19. ColorTween? rippleColorTween,
  20. Color? foregroundColor,
  21. ColorTween? foregroundColorTween,
  22. Color? longPressRippleColor,
  23. ColorTween? longPressRippleColorTween,
  24. bool useEffect = true,
  25. bool? useTapEffect,
  26. bool? useDoubleTapEffect,
  27. bool? useLongPressEffect,
  28. bool useForeground = false,
  29. bool? useTapForeground,
  30. bool? useDoubleTapForeground,
  31. bool? useLongPressForeground,
  32. double lowerPercent = 0.4,
  33. double upperPercent = 1,
  34. double? tapLowerPercent,
  35. double? tapUpperPercent,
  36. double? doubleTapLowerPercent,
  37. double? doubleTapUpperPercent,
  38. double? longPressLowerPercent,
  39. double? longPressUpperPercent,
  40. double scale = 1,
  41. double? tapScale,
  42. double? doubleTapScale,
  43. double? longPressScale,
  44. Duration rippleDuration = const Duration(milliseconds: 150),
  45. Curve rippleCurve = Curves.easeOut,
  46. Duration rippleFadeInDuration = const Duration(milliseconds: 25),
  47. Curve rippleFadeInCurve = Curves.easeOut,
  48. Duration rippleFadeOutDuration = const Duration(milliseconds: 150),
  49. Curve rippleFadeOutCurve = Curves.easeIn,
  50. Duration canceledRippleDuration = Duration.zero,
  51. Curve canceledRippleCurve = Curves.ease,
  52. Duration longPressDuration = const Duration(seconds: 1),
  53. Curve longPressCurve = Curves.linear,
  54. Duration? longPressFadeInDuration,
  55. Curve longPressFadeInCurve = Curves.linear,
  56. Duration longPressFadeOutDuration = const Duration(milliseconds: 100),
  57. Curve longPressFadeOutCurve = Curves.ease,
  58. Duration canceledLongPressDuration = Duration.zero,
  59. Curve canceledLongPressCurve = Curves.ease,
  60. Duration foregroundFadeInDuration = const Duration(milliseconds: 150),
  61. Curve foregroundFadeInCurve = Curves.easeOut,
  62. Duration foregroundFadeOutDuration = const Duration(milliseconds: 150),
  63. Curve foregroundFadeOutCurve = Curves.easeIn,
  64. Duration canceledForegroundDuration = Duration.zero,
  65. Curve canceledForegroundCurve = Curves.easeIn,
  66. required Function onTap,
  67. OnDoubleTap? onDoubleTap,
  68. Function? onDoubleTapStart,
  69. Function? onDoubleTapEnd,
  70. OnLongPress? onLongPress,
  71. Function? onHover,
  72. Function? onHoverStart,
  73. Function? onHoverEnd,
  74. Function? onCancel,
  75. OnPointer? onPointerDown,
  76. OnPointer? onPointerMove,
  77. OnPointer? onPointerUp,
  78. OnPointer? onPointerCancel,
  79. Duration tapableDuration = Duration.zero,
  80. Duration doubleTapStateDuration = const Duration(milliseconds: 250),
  81. Duration doubleTapStateCancellationDuration = const Duration(milliseconds: 500),
  82. Duration startTapEffectDuration = const Duration(milliseconds: 100),
})

Implementation

const TouchRipple({
  super.key,
  required this.child,
  this.clipBehavior = Clip.hardEdge,
  this.borderRadius = BorderRadius.zero,
  this.rippleRadius = BorderRadius.zero,
  this.cursor,
  this.doubleTapBehavior = DoubleTapBehavior.cancel,
  this.longPressBehavior = LongPressBehavior.cancel,
  this.overlapBehavior = RippleOverlapBehavior.cancel,
  RippleOverlapBehavior? tapOverlapBehavior,
  RippleOverlapBehavior? doubleTapOverlapBehavior,
  this.startTapEffect = StartTapRippleEffect.pointerDown,
  this.touchSlop = kTouchSlop,
  this.isActive = true,
  this.startOnTap = const StartOnEvent(isWait: false),
  this.startOnDoubleTap = const StartOnEvent(isWait: false),
  this.durationScale = 1,

  this.rippleColor = const Color.fromRGBO(0, 0, 0, 0.4),
  this.rippleColorTween,
  this.foregroundColor,
  this.foregroundColorTween,
  this.longPressRippleColor,
  this.longPressRippleColorTween,

  this.useEffect = true,
  bool? useTapEffect,
  bool? useDoubleTapEffect,
  bool? useLongPressEffect,
  this.useForeground = false,
  bool? useTapForeground,
  bool? useDoubleTapForeground,
  bool? useLongPressForeground,

  this.lowerPercent = 0.4,
  this.upperPercent = 1,
  double? tapLowerPercent,
  double? tapUpperPercent,
  double? doubleTapLowerPercent,
  double? doubleTapUpperPercent,
  double? longPressLowerPercent,
  double? longPressUpperPercent,

  this.scale = 1,
  double? tapScale,
  double? doubleTapScale,
  double? longPressScale,

  this.rippleDuration = const Duration(milliseconds: 150),
  this.rippleCurve = Curves.easeOut,
  this.rippleFadeInDuration = const Duration(milliseconds: 25),
  this.rippleFadeInCurve = Curves.easeOut,
  this.rippleFadeOutDuration = const Duration(milliseconds: 150),
  this.rippleFadeOutCurve = Curves.easeIn,
  this.canceledRippleDuration = Duration.zero,
  this.canceledRippleCurve = Curves.ease,
  this.longPressDuration = const Duration(seconds: 1),
  this.longPressCurve = Curves.linear,
  Duration? longPressFadeInDuration,
  this.longPressFadeInCurve = Curves.linear,
  this.longPressFadeOutDuration = const Duration(milliseconds: 100),
  this.longPressFadeOutCurve = Curves.ease,
  this.canceledLongPressDuration = Duration.zero,
  this.canceledLongPressCurve = Curves.ease,
  this.foregroundFadeInDuration = const Duration(milliseconds: 150),
  this.foregroundFadeInCurve = Curves.easeOut,
  this.foregroundFadeOutDuration = const Duration(milliseconds: 150),
  this.foregroundFadeOutCurve = Curves.easeIn,
  this.canceledForegroundDuration = Duration.zero,
  this.canceledForegroundCurve = Curves.easeIn,

  required this.onTap,
  this.onDoubleTap,
  this.onDoubleTapStart,
  this.onDoubleTapEnd,
  this.onLongPress,
  this.onHover,
  this.onHoverStart,
  this.onHoverEnd,
  this.onCancel,
  this.onPointerDown,
  this.onPointerMove,
  this.onPointerUp,
  this.onPointerCancel,

  this.tapableDuration = Duration.zero,
  this.doubleTapStateDuration = const Duration(milliseconds: 250),
  this.doubleTapStateCancellationDuration = const Duration(milliseconds: 500),
  this.startTapEffectDuration = const Duration(milliseconds: 100),
}) : assert(!(lowerPercent > 1 || lowerPercent < 0), 'The value from is 0.0 to 1.0'),
     assert(!(upperPercent > 1 || upperPercent < 0), 'The value from is 0.0 to 1.0'),
     assert(!(scale <= 0), 'The scale must be greater than zero, If you do not want to use an ripple effect define useEffect as false'),
     assert(!(durationScale < 0), 'The duration spped scale must be greater than negative number'),
     assert(doubleTapStateDuration != Duration.zero, 'Must be greater than Duration.zero'),
     assert(doubleTapStateCancellationDuration != Duration.zero, 'Must be greater than Duration.zero'),

     tapOverlapBehavior = tapOverlapBehavior ?? overlapBehavior,
     doubleTapOverlapBehavior = doubleTapOverlapBehavior ?? overlapBehavior,

     useTapEffect = useTapEffect ?? useEffect,
     useDoubleTapEffect = useDoubleTapEffect ?? useEffect,
     useLongPressEffect = useLongPressEffect ?? useEffect,
     useTapForeground = useTapForeground ?? useForeground,
     useDoubleTapForeground = useDoubleTapForeground ?? useForeground,
     useLongPressForeground = useLongPressForeground ?? useForeground,

     tapLowerPercent = tapLowerPercent ?? lowerPercent,
     tapUpperPercent = tapUpperPercent ?? upperPercent,
     doubleTapLowerPercent = doubleTapLowerPercent ?? lowerPercent,
     doubleTapUpperPercent = doubleTapUpperPercent ?? upperPercent,
     longPressLowerPercent = longPressLowerPercent ?? lowerPercent,
     longPressUpperPercent = longPressUpperPercent ?? upperPercent,

     tapScale = tapScale ?? scale,
     doubleTapScale = doubleTapScale ?? scale,
     longPressScale = longPressScale ?? scale,

     longPressFadeInDuration = longPressFadeInDuration ?? longPressDuration;