CustomInkRipple constructor
CustomInkRipple({
- required MaterialInkController controller,
- required RenderBox referenceBox,
- required Offset position,
- required Color color,
- required TextDirection textDirection,
- bool containedInkWell = false,
- RectCallback? rectCallback,
- BorderRadius? borderRadius,
- ShapeBorder? customBorder,
- double? radius,
- VoidCallback? onRemoved,
- CustomInkRippleSetting setting = CustomInkRippleSetting.defaultSetting,
Implementation
CustomInkRipple({
required MaterialInkController controller,
required RenderBox referenceBox,
required Offset position,
required Color color,
required TextDirection textDirection,
bool containedInkWell = false,
RectCallback? rectCallback,
BorderRadius? borderRadius,
ShapeBorder? customBorder,
double? radius,
VoidCallback? onRemoved,
CustomInkRippleSetting setting = CustomInkRippleSetting.defaultSetting,
}) : _position = position,
_borderRadius = borderRadius ?? BorderRadius.zero,
_customBorder = customBorder,
_textDirection = textDirection,
_targetRadius = radius ?? _getTargetRadiusForRipple(referenceBox, containedInkWell, rectCallback, position),
_clipCallback = _getClipCallback(referenceBox, containedInkWell, rectCallback),
_setting = setting,
super(controller: controller, referenceBox: referenceBox, color: color, onRemoved: onRemoved) {
// Immediately begin fading-in the initial splash.
_fadeInController = AnimationController(duration: _setting.unconfirmedFadeInDuration /* _kFadeInDuration */, vsync: controller.vsync)
..addListener(controller.markNeedsPaint)
..forward(); // <<<
_fadeIn = _fadeInController.drive(IntTween(
begin: 0,
end: color.alpha,
));
// Controls the splash radius and its center. Starts upon confirm.
_radiusController = AnimationController(duration: _setting.unconfirmedRippleDuration /* _kUnconfirmedRippleDuration */, vsync: controller.vsync)
..addListener(controller.markNeedsPaint)
..forward(); // <<<
// Initial splash diameter is 60% of the target diameter, final
// diameter is 10dps larger than the target diameter.
_radius = _radiusController.drive(
Tween<double>(
begin: _setting.radiusAnimationBeginFn?.call(_targetRadius) ?? _targetRadius * 0.30,
end: _setting.radiusAnimationEndFn?.call(_targetRadius) ?? _targetRadius + 5.0,
).chain(_easeCurveTween),
);
// Controls the splash radius and its center. Starts upon confirm however its
// Interval delays changes until the radius expansion has completed.
_fadeOutController = AnimationController(duration: _setting._confirmedFadeOutDuration /* _kFadeOutDuration */, vsync: controller.vsync)
..addListener(controller.markNeedsPaint)
..addStatusListener(_handleAlphaStatusChanged);
_fadeOutIntervalTween = CurveTween(curve: Interval(_setting._confirmedFadeOutInterval /* _kFadeOutIntervalStart */, 1.0));
_fadeOut = _fadeOutController.drive(
IntTween(
begin: color.alpha,
end: 0,
).chain(_fadeOutIntervalTween),
);
controller.addInkFeature(this);
}