TouchRipple constructor
const
TouchRipple({
- Key? key,
- required Widget child,
- Clip clipBehavior = Clip.hardEdge,
- BorderRadius borderRadius = BorderRadius.zero,
- BorderRadius rippleRadius = BorderRadius.zero,
- SystemMouseCursor? cursor,
- DoubleTapBehavior doubleTapBehavior = DoubleTapBehavior.cancel,
- LongPressBehavior longPressBehavior = LongPressBehavior.cancel,
- RippleOverlapBehavior overlapBehavior = RippleOverlapBehavior.cancel,
- RippleOverlapBehavior? tapOverlapBehavior,
- RippleOverlapBehavior? doubleTapOverlapBehavior,
- StartTapRippleEffect startTapEffect = StartTapRippleEffect.pointerDown,
- double touchSlop = kTouchSlop,
- bool isActive = true,
- StartOnEvent startOnTap = const StartOnEvent(isWait: false),
- StartOnEvent startOnDoubleTap = const StartOnEvent(isWait: false),
- double durationScale = 1,
- Color rippleColor = const Color.fromRGBO(0, 0, 0, 0.4),
- ColorTween? rippleColorTween,
- Color? foregroundColor,
- ColorTween? foregroundColorTween,
- Color? longPressRippleColor,
- ColorTween? longPressRippleColorTween,
- bool useEffect = true,
- bool? useTapEffect,
- bool? useDoubleTapEffect,
- bool? useLongPressEffect,
- bool useForeground = false,
- bool? useTapForeground,
- bool? useDoubleTapForeground,
- bool? useLongPressForeground,
- double lowerPercent = 0.4,
- double upperPercent = 1,
- double? tapLowerPercent,
- double? tapUpperPercent,
- double? doubleTapLowerPercent,
- double? doubleTapUpperPercent,
- double? longPressLowerPercent,
- double? longPressUpperPercent,
- double scale = 1,
- double? tapScale,
- double? doubleTapScale,
- double? longPressScale,
- Duration rippleDuration = const Duration(milliseconds: 150),
- Curve rippleCurve = Curves.easeOut,
- Duration rippleFadeInDuration = const Duration(milliseconds: 25),
- Curve rippleFadeInCurve = Curves.easeOut,
- Duration rippleFadeOutDuration = const Duration(milliseconds: 150),
- Curve rippleFadeOutCurve = Curves.easeIn,
- Duration canceledRippleDuration = Duration.zero,
- Curve canceledRippleCurve = Curves.ease,
- Duration longPressDuration = const Duration(seconds: 1),
- Curve longPressCurve = Curves.linear,
- Duration? longPressFadeInDuration,
- Curve longPressFadeInCurve = Curves.linear,
- Duration longPressFadeOutDuration = const Duration(milliseconds: 100),
- Curve longPressFadeOutCurve = Curves.ease,
- Duration canceledLongPressDuration = Duration.zero,
- Curve canceledLongPressCurve = Curves.ease,
- Duration foregroundFadeInDuration = const Duration(milliseconds: 150),
- Curve foregroundFadeInCurve = Curves.easeOut,
- Duration foregroundFadeOutDuration = const Duration(milliseconds: 150),
- Curve foregroundFadeOutCurve = Curves.easeIn,
- Duration canceledForegroundDuration = Duration.zero,
- Curve canceledForegroundCurve = Curves.easeIn,
- required Function onTap,
- OnDoubleTap? onDoubleTap,
- Function? onDoubleTapStart,
- Function? onDoubleTapEnd,
- OnLongPress? onLongPress,
- Function? onHover,
- Function? onHoverStart,
- Function? onHoverEnd,
- Function? onCancel,
- OnPointer? onPointerDown,
- OnPointer? onPointerMove,
- OnPointer? onPointerUp,
- OnPointer? onPointerCancel,
- Duration tapableDuration = Duration.zero,
- Duration doubleTapStateDuration = const Duration(milliseconds: 250),
- Duration doubleTapStateCancellationDuration = const Duration(milliseconds: 500),
- 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;