Foil.colored constructor
- Key? key,
- bool isUnwrapped = false,
- double opacity = 1.0,
- bool useSensor = true,
- required List<
Color> colors, - BlendMode blendMode = BlendMode.srcATop,
- Scalar scalar = Scalar.identity,
- Gradient? unwrappedGradient,
- required Widget child,
- Duration speed = const Duration(milliseconds: 150),
- Duration duration = const Duration(milliseconds: 500),
- Curve curve = Curves.ease,
- VoidCallback? onEnd,
Wrap a widget with colored Foil , providing a dynamic shimmer that twinkles as the accelerometer moves, colored by a looping LinearGradient formed from colors . |
---|
Paramater bool isUnwrapped toggles a Foil 's invisibility. Default is false. |
---|
Accelerometer
Disable this Foil
's reaction to accelerometer sensor motion by
useSensor: false
. Default is true
.
Influence the intensity of this Foil
's reaction to accelerometer motion
by providing a custom Scalar
scalar. Default is Scalar.identity
which has both a horizontal
and vertical
multiplier of +1.0
.
(Not to be confused with a potential and optional Crinkle.scalar
,
provided by wrapping Foil
in a Roll
and declaring Roll.crinkle
.
This Scalar is used to scale axis-dependent animation values.)
Using a Roll
of Foil
Optionally a Roll may be deployed higher up in the widget tree.
This ancestor offers two additional features to any Foil underneath it.
Either declare a Roll.gradient to which any descendent Foil
may fallback and/or provide a Roll.crinkle to make declarations about
gradient animation beyond accelerometer sensors data.
See Crinkle for more information.
Transitioning
Control how rapidly this Foil
transforms its gradient
with speed and define the animation curve.
Defaults are 150ms
and Curves.ease.
Furthermore, provide duration to dictate how long
intrinsic animations of this Foil
's colors
will take.
duration is also used if isUnwrapped is made true
as the duration
over which to Gradient.lerp to a transparent gradient for tweening.
Upon completion of any tween to a new colors
, this Foil
will
call onEnd, an optional void callback.
Implementation
Foil.colored({
Key? key,
this.isUnwrapped = false,
this.opacity = 1.0,
this.useSensor = true,
required List<Color> colors,
this.blendMode = BlendMode.srcATop,
this.scalar = Scalar.identity,
this.unwrappedGradient,
required this.child,
this.speed = const Duration(milliseconds: 150),
this.duration = const Duration(milliseconds: 500),
this.curve = Curves.ease,
this.onEnd,
}) : sheet = const Sheet(),
_box = null,
// TODO: update default
gradient = LinearGradient(
colors: colors + colors.reversed.toList(),
tileMode: TileMode.mirror,
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
super(key: key);