Implicit Flutter Animations

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

Part 2: Implicit Animations in Action

05. Animate a Social Share Button

Episode complete

Play next episode

About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 04. Create Custom Implicit Animations Next episode: 06. Create a Custom PageView Animation

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: 05. Animate a Social Share Button

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

The updated material uses null safety and also deploys the use coding practises encouraged by the Flutter as per the Flutter lint rules and a few addons of practises that are considered good here at raywenderlich (see analysis_options.yaml in the material for more info).

Also, since the Flutter 2, it is now necessary to explicitly specify the type that an expression or method can return. If dart is unable to infer the actual type but assumes it return generic type like Object? then it is necessary to casting to actual type as well.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

In this section, we are going to apply our knowledge of implicit animations to add animations to the RW-Eats app. We would be covering more implicitly animated widgets.

    //width: 48,
    width: 240,
    //opacity: 0,
    opacity: 1,
bool isOpen = false;

void _toggleShare() {
    setState(() {
      isOpen = !isOpen;
    duration: const Duration(milliseconds: 350),
    curve: Curves.fastOutSlowIn,
    width: isOpen ? 240 : 48,
    child: IconButton(
        icon: const Icon(Icons.share),
        onPressed: () => _toggleShare(),
    duration: const Duration(milliseconds: 450),
    opacity: isOpen ? 1 : 0,
child: AnimatedCrossFade(
    duration: const Duration(milliseconds: 450),
    firstChild: IconButton(
      icon: const Icon(Icons.share),
      onPressed: () => _toggleShare(),
    secondChild: IconButton(
      icon: const Icon(Icons.close),
      onPressed: () => _toggleShare(),
    crossFadeState: !isOpen
        ? CrossFadeState.showFirst
        : CrossFadeState.showSecond,