
Animations in many iOS apps feel physical: they spring rather than ease, they can be grabbed and
reversed halfway, and a flick carries its speed into the motion that follows. This guide shows how to get
those qualities in Flutter with ExpandableAnimation, on every platform Flutter supports.
This is a set of interaction patterns, not a copy of Apple's system animations. Everything is drawn by Flutter; the package does not use UIKit, and the timings are its own.
1. Springs instead of curves
A spring has no fixed duration: it settles when its energy runs out. Pass
physics to replace duration and curve:
ExpandableAnimation(
physics: ExpandableAnimationPhysics.bouncy, // gentle overshoot
expandedBuilder: (context) => const ArticlePage(),
child: const ArticleCard(),
)
The presets are smooth (no overshoot), bouncy (gentle overshoot) and
snappy (fast, small overshoot). For your own spring, use
ExpandableAnimationPhysics.spring(stiffness: 260, dampingRatio: 0.8). A damping ratio below
1.0 overshoots on expansion; the collapse always uses a critically damped version so the view
never shrinks past its source.
2. Interruptible transitions
Users can change their mind mid-animation. While the expanded view is being dragged, moving the finger
back restores it, and releasing below the threshold springs it back. From code,
controller.collapse() while the card is still opening reverses it from where it is, and
controller.expand() during a collapse does the same in the other direction. There is no jump
back to the start.
final controller = ExpandableAnimationController();
ExpandableAnimation(
controller: controller,
physics: ExpandableAnimationPhysics.snappy,
expandedBuilder: (context) => const DetailsPage(),
child: const SummaryCard(),
);
// Later, even halfway through a collapse:
controller.expand();
3. Gestures that carry their speed
Pulling the expanded view down shrinks it under the finger. On release, the collapse starts from that exact position at the speed of the finger, so a quick flick closes quickly and a slow release eases home. This is on by default:
gestureConfig: const ExpandableAnimationGestureConfig(
matchReleaseVelocity: true, // default
minScale: 0.85, // how small the view gets while dragged
dragResistance: 0.6, // the view moves slower than the finger
enableHapticFeedback: true, // light tick when crossing the threshold
),
See drag-to-dismiss for thresholds, directions and scrollable content.
4. Depth: blur and dimming
A blurred, dimmed background keeps the previous screen visible while separating it from the new one:
ExpandableAnimation(
backgroundBlur: 6,
backgroundOpacity: 0.3,
...
)
Background blur is the most expensive option, especially on mid-range Android phones. Check the measured frame times and keep the radius small or leave it off on low-end hardware.
5. Sheets and centered panels
Not every expansion should take the whole screen. A partial-height sheet or a centered panel keeps context, and both move out of the way of the keyboard:
mode: const ExpandableAnimationMode.sheet(heightFactor: 0.6, maxWidth: 640),
// or
mode: const ExpandableAnimationMode.dialog(maxSize: Size(480, 640)),
6. Shared elements
Artwork that appears in both the card and the detail view can fly on its own path inside the morph
with ExpandableAnimationSlot. See the
shared element transition guide.
7. Respect reduced motion
When the user turns on reduced motion in the system settings, transitions become instant
(respectReducedMotion, on by default). Keep it on: motion-sensitive users still get the same
result without the movement.
Putting it together
ExpandableAnimation(
borderRadius: BorderRadius.circular(24),
physics: ExpandableAnimationPhysics.snappy,
backgroundBlur: 6,
backgroundOpacity: 0.3,
gestureConfig: const ExpandableAnimationGestureConfig(minScale: 0.85),
semanticLabel: 'Read ${story.title}',
expandedBuilder: (context) => ArticlePage(story: story),
child: StoryCard(story: story),
)
This works in MaterialApp, CupertinoApp and WidgetsApp. Try
it in the App Store-style cards demo, or tune the spring in
the playground.