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. required Widget child,
  10. Duration speed = const Duration(milliseconds: 150),
  11. Duration duration = const Duration(milliseconds: 500),
  12. Curve curve = Curves.ease,
  13. VoidCallback? onEnd,
})
accelerometer-animated Foil Wrap a widget with colored Foil, providing a dynamic shimmer that twinkles as the accelerometer moves, colored by a looping LinearGradient formed from colors.
unwrapping Foil 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);