TiltProjectorContainer widget

Learn about TiltProjectorContainer widget parameters. TiltProjectorContainer widget will have tilt and projector-like shadow effects.

TiltProjectorContainer widget can only be used in the Tilt widget.

Apply a shadow to the entire child and childLayout, similar to a projector effect.
It will display a shadow that exactly matches the non-transparent parts of the widget.

Performance risk exists

Recommended for the following scenarios:

  • Images only
  • No data states
  • No Hero tags

You should assess the performance risks yourself.
If your scenario runs smoothly, then you can use it.

Simple usage

...

final childLayout = ChildLayout(
  outer: [
    TiltParallax(
      offset: Offset(20, 20),
      child: Image.asset(
        'assets/demo1.png',
        width: xxx,
        height: xxx,
      ),
    ),
    TiltParallax(
      offset: Offset(30, 30),
      child: Image.asset(
        'assets/demo2.png',
        width: xxx,
        height: xxx,
      ),
    ),
  ],
);

...

/// Tilt with TiltProjectorContainer for effects.
Tilt(
  child: TiltProjectorContainer(
    childLayout: childLayout,
    child: SizedBox(width: 150, height: 300),
  ),
),

/// Tilt with built-in Tilt.projector for effects.
/// Tilt.projector is a convenient widget that composes Tilt and TiltProjectorContainer.
Tilt.projector(
  childLayout: childLayout,
  child: SizedBox(width: 150, height: 300),
),

...

TiltProjectorContainer widget parameters

ParameterTypeDefaultDescription
child requiredWidget-The main child widget to which tilt and effects are applied.
childLayoutChildLayoutChildLayout()Other child layouts.
e.g. parallax outer, inner, behind.
shadowConfigShadowProjectorConfigShadowProjectorConfig()Shadow effect config.
borderBoxBorder?nullBoxDecoration border.
borderRadiusBorderRadiusGeometry?nullBoxDecoration borderRadius.
clipBehaviorClipClip.antiAliasClip behavior for the container.
filterQualityFilterQuality?nullFilter quality for the transform.

ChildLayout

ParameterTypeDefaultDescription
outerList<Widget><Widget>[]As with Stack, you can use the Stack layout to create widgets that are outer of the child.
e.g. parallax effects.
innerList<Widget><Widget>[]As with Stack, you can use the Stack layout to create widgets that are inner of the child.
e.g. parallax effects.
behindList<Widget><Widget>[]As with Stack, you can use the Stack layout to create widgets that are behind of the child.
e.g. parallax effects.

ShadowProjectorConfig

ParameterTypeDefaultDescription
disableboolfalseOnly disable the shadow effect.
colorColorColor(0xFF9E9E9E)Shadow color.
minIntensitydouble0.0Color minimum opacity, also initial opacity.
maxIntensitydouble0.5Color maximum opacity as tilt progresses.
offsetInitialOffsetOffset(0.0, 0.0)Initial value of shadow offset.
e.g. (0.0, 0.0) center.
(40.0, 40.0) Offset 40 to the top left.
offsetFactordouble0.1Shadow offset factor, relative to current widget size.
directionShadowDirection?nullShadow direction.
enableReversebool?nullReverse shadow direction.
projectorScaleFromdouble1.0Size scale for minimum progress, also initial size scale.
projectorScaleTodouble1.0Size scale for maximum progress.
projectorBlurSigmaFromdouble5.0Blur sigma for minimum progress, also initial blur sigma.
projectorBlurSigmaTodouble10.0Blur sigma for maximum progress.