ShaderInkFeatureFactory class
Allows customization of the material inkwell effect with a user authored fragment shader.
On each frame of the inkwell animation, the provided callback will be invoked with a fragment shader instance, as well as the configuration for the particular inkwell splash that is occuring. It is the responsibility of the developer to supply both a fragment program and a callback that delivers the ink well effect.
Example:
Configuring all inkwells in a material application with a fragment program.
#include <flutter/runtime_effect.glsl>
uniform float uAnimation;
uniform vec4 uColor;
uniform float uRadius;
uniform vec2 uCenter;
out vec4 fragColor;
void main() {
float scale = distance(FlutterFragCoord(), uCenter) / uRadius;
fragColor = mix(vec4(1.0), uColor, scale) * (1.0 - uAnimation);
}
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
splashFactory: ShaderInkFeatureFactory(program, (
shader, {
required double animation,
required Color color,
required Offset position,
required Size referenceBoxSize,
required double targetRadius,
required TextDirection textDirection,
}) {
shader
..setFloat(0, animation)
..setFloat(1, color.red / 255.0 * color.opacity)
..setFloat(2, color.green / 255.0 * color.opacity)
..setFloat(3, color.blue / 255.0 * color.opacity)
..setFloat(4, color.opacity)
..setFloat(5, targetRadius)
..setFloat(6, position.dx)
..setFloat(7, position.dy);
})),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
See also:
- ShaderInkFeature for more information on the available configuration.
- Inheritance
-
- Object
- InteractiveInkFeatureFactory
- ShaderInkFeatureFactory
Constructors
- ShaderInkFeatureFactory(FragmentProgram program, ShaderConfigCallback callback, {Duration animationDuration = const Duration(milliseconds: 617)})
-
const
Properties
- animationDuration → Duration
-
final
- callback → ShaderConfigCallback
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- program → FragmentProgram
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
create(
{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}) → InteractiveInkFeature -
The factory method.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited