Implicit Flutter Animations

Oct 4 2022 · Dart 2.17, Flutter 3.0, Visual Studio Code 1.7

Part 1: Animation Fundamentals

04. Create Custom Implicit Animations

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 03. Add Realistic Motions with Curves Next episode: 05. Animate a Social Share Button

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Notes: 04. Create Custom Implicit Animations

The student materials have been reviewed and are updated as of August 2022.

The updated material uses null safety and also deploys the use of const keyword with constant constructors, use of single quotes over double quotes as per the Flutter lint rules that is used to encourage good coding practises. Also, the return value of the Tween variable is explicitly mentioned to avoids errors of passing the incompatatible Tween to TweenAnimtionBuilder.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

In earlier episodes, we introduced ImplicitlyAnimatedWidgets. We saw that Flutter provides lots of these ready made widgets and all we have to do is to find the one that suits our animation needs.

...
TweenAnimationBuilder(
    duration: const Duration(milliseconds: 500),
    tween: Tween<double>(begin: 0.0, end: progress),
    builder: (_, double value, __) {
        return Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
                CircularProgressIndicator(
                    value: value,
                ),
                Text("${(value * 100).round()}"),
            ],
        );
    },
),
...
...
static final Tween<double> fabTween = Tween(begin: 0.0, end: 1.0);
...
floatingActionButton: TweenAnimationBuilder<double>(
    duration: const Duration(milliseconds: 500),
    curve: Curves.bounceOut,
    tween: fabTween,
    child: FloatingActionButton(
        onPressed: progress > 0.9
            ? null
            : () {
                setState(() {
                progress += 0.1;
                });
            },
        tooltip: 'Increment',
        child: const Icon(Icons.add),
    ),
    builder: (_, value, child) {
        // return Transform.rotate(
        return Transform.scale(
            scale: value,
            // angle: pi*value,
            child: child,
        );
    },
),
...