Material Transitions in Flutter with the Animations Package

Sep 21 2021 · Dart 2.13, Flutter, VS Code 1.59

Part 1: Material Transitions in Flutter with the Animations Package

02. Understand the Container Transform Animation

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: 01. Get Introduced to the Material Motion System Next episode: 03. Create a FadeThrough 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.

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

Let’s dive deeper into the OpenContainer widget by using it with a custom widget. For this episode, we’ll be animating the card from the home to the detail page. Currently, if we click the card, it navigates to the detail page using the platform specific route animation. Let’s change that up to a container transform animation.

OpenContainer(
    closedBuilder: (BuildContext _, VoidCallback openContainer) {
        return ArticleCard(
            article: article,
        );
    },
    openBuilder: (BuildContext _, CloseContainerActionCallback closeContainer) {
        return ArticlePage(
            article: article,
        );
    },
),
padding: const EdgeInsets.all(16),
const SizedBox(height: 16),
closedElevation: 4,
transitionType: ContainerTransitionType.fadeThrough,
...
tappable: false,
closedBuilder: (BuildContext _, VoidCallback openContainer) {
    return GestureDetector(
    onTap: () {
        openContainer();
        print("Container Opening...Do Something here...");
    },
    child: ArticleCard(article: article),
    );
},
onClosed: (result) {
    print("Container closed");
    print("We can reload the list of articles here");
    print(result);
},
leading: IconButton(
    onPressed: () {
        // Navigator.pop(context); // Default pop() implementation
        Navigator.pop(context, "Data from the Article Page");
    },
    icon: const Icon(Icons.arrow_back),
),