A container transform turns one element into another by morphing the container that holds them: its bounds, its corners and its color change together while the content cross-fades. It keeps a strong visual link between where the user tapped and what opened.

What morphs

PropertyFromTo
BoundsThe child's on-screen rectangleThe rectangle resolved by mode
Corner radiusborderRadiusexpandedBorderRadius
Surface colorcollapsedColorexpandedColor
ContentThe childThe expandedBuilder result (cross-fade)
BackgroundTransparentbackgroundColor at backgroundOpacity, optional blur
ExpandableAnimation(
  mode: const ExpandableAnimationMode.dialog(maxSize: Size(760, 560)),
  borderRadius: BorderRadius.circular(18),
  expandedBorderRadius: BorderRadius.circular(28),
  collapsedColor: scheme.surfaceContainerHigh,
  expandedColor: scheme.surfaceContainerLow,
  backgroundOpacity: 0.35,
  backgroundBlur: 8,
  expandedBuilder: (context) => MetricDetails(metric: metric),
  child: MetricTile(metric: metric),
)

How the content stays smooth

Both the child and the expanded view are laid out once at their own natural size and then scaled to the width of the morphing surface, aligned to the top. Because their constraints never change during the animation, Flutter does not re-run their layout every frame — only a scale transform and a clip change. This keeps heavy expanded pages cheap to animate.

Reversing correctly

When collapsing, the child's position is measured again. If the list scrolled or the window resized while the view was open, the surface lands where the child is now. If the child is gone entirely, the view fades out in place instead of flying to a stale position.

Try it

Open the dashboard demo (dialog on wide windows) or the playground. Related: morphing with springs and custom layers.