Skip to main content

Flutter animation example

Flutter Hero Animation: Product List to Detail Transition

Flutter's Hero widget moves one element between routes. This example goes a step further: the product image follows a curved path instead of a straight line, the detail page is revealed by a circle that grows from the tapped item, and the price and button rise in afterwards. Back reverses it.

  • 4.5 KB file
  • 4 live inputs
  • Flutter runtime
Live, try it

How this hero product transition works

  • The image's position follows a quadratic curve, which looks more natural than a straight Hero path.
  • The detail page is clipped by a circle centred on the tapped row; its radius eases to cover the screen.
  • Events "open" and "close" fire on each direction.

Add it to your Flutter app

Install exodeui_flutter, download the file below, and paste this. The code updates as you customize. Other runtimes are in the other tabs.

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:exodeui_flutter/exodeui_flutter.dart';

// Add assets/flutter-hero-animation.exode to pubspec.yaml (download it below).
class FlutterHeroAnimation extends StatefulWidget {
  const FlutterHeroAnimation({super.key});
  @override
  State<FlutterHeroAnimation> createState() => _FlutterHeroAnimationState();
}

class _FlutterHeroAnimationState extends State<FlutterHeroAnimation> {
  final _canvas = GlobalKey<ExodeUICanvasState>();
  late final Future<String> _json = rootBundle.loadString('assets/flutter-hero-animation.exode');

  @override
  Widget build(BuildContext context) {
    return FutureBuilder<String>(
      future: _json,
      builder: (context, snap) => snap.hasData
          ? ExodeUICanvas(
              key: _canvas,
              artboardJson: snap.data!,
              fit: 'Layout',
              onReady: () { },
              onTrigger: (name, _) {
                // fires: 'open', 'close'
              },
            )
          : const SizedBox.shrink(),
    );
  }
}

Inputs

InputTypeDefaultRange
durationNumber0.60.2 – 1.5
accentText#22c55ehex colour
inkText#0f172ahex colour
bgText#f1f5f9hex colour

Events: openclose

More Flutter animations

The same idea in other frameworks: React shared element transition · JavaScript curtain wipe transition · Vue slide and fade route transition