Foil.colored constructor

Foil.colored({
  1. Key? key,
  2. bool isUnwrapped = false,
  3. double opacity = 1.0,
  4. bool useSensor = true,
  5. required List<Color> colors,
  6. BlendMode blendMode = BlendMode.srcATop,
  7. Scalar scalar = Scalar.identity,
  8. Gradient? unwrappedGradient,
  9. bool isAgressive = true,
  10. required Widget child,
  11. Duration speed = const Duration(milliseconds: 150),
  12. Duration duration = const Duration(milliseconds: 500),
  13. Curve curve = Curves.ease,
  14. VoidCallback? onEnd,
})

pointer-animated Foil

Wrap a widget with Foil, providing a rainbow shimmer that twinkles as the pointer moves.

unwrapping Foil Paramater bool isUnwrapped toggles a Foil's invisibility. Default is false.

Pointer Tracking

Disable this Foil's reaction to pointer movement by useSensor: false. Default is true.

Influence the intensity of this Foil's reaction to pointer movement 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,
  this.isAgressive = true,
  required this.child,
  this.speed = const Duration(milliseconds: 150),
  this.duration = const Duration(milliseconds: 500),
  this.curve = Curves.ease,
  this.onEnd,
}) : sheet = const Sheet(),
     // irrelevant in this context
     box = null,
     // irrelevant in this context
     // TODO: update default
     gradient = LinearGradient(
       colors: colors + colors.reversed.toList(),
       tileMode: TileMode.mirror,
       begin: Alignment.topLeft,
       end: Alignment.bottomRight,
     ),
     super(key: key);