Foil constructor

const Foil({
  1. Key? key,
  2. bool isUnwrapped = false,
  3. double opacity = 1.0,
  4. bool useSensor = true,
  5. Gradient? gradient,
  6. BlendMode blendMode = BlendMode.srcATop,
  7. Scalar scalar = const Scalar(),
  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 Foil, providing a rainbow shimmer that twinkles as the accelerometer moves.

The "rainbow" may be any gradient of choice.
Some pre-rolled are available in Foils.

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 gradient will take. duration is also used if isUnwrapped is made true as the duration over which gradient will Gradient.lerp to an appropriately-Typed transparent gradient for tweening.

There is hard-coded recognition for linear, radial, and sweep Gradients,
as well as the additional LinearSteps, RadialSteps, and SweepSteps
variants that this package provides. Falls back to LinearGradient (nillLG) if Type cannot be matched.

Upon completion of any tween to a new gradient, this Foil will call onEnd, an optional void callback.

Implementation

const Foil({
  Key? key,
  this.isUnwrapped = false,
  this.opacity = 1.0,
  this.useSensor = true,
  this.gradient,
  this.blendMode = BlendMode.srcATop,
  this.scalar = const Scalar(),
  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,
      super(key: key);