build method
Widget
build({
- required Animation<
double> animation, - required Widget child,
- Map<
String, Object?> params = const {},
override
Builds the animated widget for the forward direction.
animation — 0.0 → 1.0 where 0.0 = invisible/start, 1.0 = visible/end.
child — the widget being animated.
params — optional configuration map (typed by each plugin).
Concrete subclasses must override this method.
Implementation
@override
Widget build({
required Animation<double> animation,
required Widget child,
Map<String, Object?> params = const {},
}) {
final base =
(params['base'] as Color?) ?? const Color(0xFFE0E0E0);
final highlight =
(params['highlight'] as Color?) ?? const Color(0xFFF5F5F5);
return AnimatedBuilder(
animation: animation,
builder: (_, c) {
final t = animation.value;
// Sweep from left (-1) to right (+1) over the animation
final sweep = -1.0 + t * 3.0; // goes -1 → 2
return ShaderMask(
blendMode: BlendMode.srcATop,
shaderCallback: (rect) => LinearGradient(
begin: Alignment(sweep - 1.0, 0.0),
end: Alignment(sweep + 1.0, 0.0),
colors: [base, highlight, base],
stops: const [0.0, 0.5, 1.0],
).createShader(rect),
child: c,
);
},
child: child,
);
}