InkSparkle class

Begin a Material 3 ink sparkle ripple, centered at the tap or click position relative to the referenceBox.

This effect relies on a shader and therefore is unsupported on the Flutter Web HTML backend.

To use this effect, pass an instance of splashFactory to the splashFactory parameter of either the Material ThemeData or any component that has a splashFactory parameter, such as buttons:

The controller argument is typically obtained via Material.of(context).

If containedInkWell is true, then the effect will be sized to fit the well rectangle, and clipped to it when drawn. The well rectangle is the box returned by rectCallback, if provided, or otherwise is the bounds of the referenceBox.

If containedInkWell is false, then rectCallback should be null. The ink ripple is clipped only to the edges of the Material. This is the default.

When the ripple is removed, onRemoved will be called.

For typical use, pass the InkSparkle.splashFactory to the splashFactory parameter of a button style or ThemeData.
link
ElevatedButton(
  style: ElevatedButton.styleFrom(splashFactory: InkSparkle.splashFactory),
  child: const Text('Sparkle!'),
  onPressed: () { },
)

Inheritance

Constructors

InkSparkle({required MaterialInkController controller, required RenderBox referenceBox, required Color color, required Offset position, required TextDirection textDirection, bool containedInkWell = true, RectCallback? rectCallback, BorderRadius? borderRadius, ShapeBorder? customBorder, double? radius, VoidCallback? onRemoved, double? turbulenceSeed})
Begin a sparkly ripple effect, centered at position relative to referenceBox.

Properties

color Color
The ink's color.
getter/setter pairinherited
controller MaterialInkController
The MaterialInkController associated with this InkFeature.
no setterinherited
customBorder ShapeBorder?
The ink's optional custom border.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
onRemoved VoidCallback?
Called when the ink feature is no longer visible on the material.
finalinherited
referenceBox RenderBox
The render box whose visual position defines the frame of reference for this ink feature.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

cancel() → void
Called when the user input that triggered this feature's appearance was canceled.
inherited
confirm() → void
Called when the user input that triggered this feature's appearance was confirmed.
inherited
dispose() → void
Free up the resources associated with this ink feature.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
paintFeature(Canvas canvas, Matrix4 transform) → void
Override this method to paint the ink feature.
override
paintInkCircle({required Canvas canvas, required Matrix4 transform, required Paint paint, required Offset center, required double radius, TextDirection? textDirection, ShapeBorder? customBorder, BorderRadius borderRadius = BorderRadius.zero, RectCallback? clipCallback}) → void
Draws an ink splash or ink ripple on the passed in Canvas.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

constantTurbulenceSeedSplashFactory → const InteractiveInkFeatureFactory
Used to specify this type of ink splash for an InkWell, InkResponse, material Theme, or ButtonStyle.
splashFactory → const InteractiveInkFeatureFactory
Used to specify this type of ink splash for an InkWell, InkResponse, material Theme, or ButtonStyle.