Reader small image

You're reading from  Flutter Cookbook, Second Edition - Second Edition

Product typeBook
Published inMay 2023
Reading LevelIntermediate
PublisherPackt
ISBN-139781803245430
Edition2nd Edition
Languages
Tools
Right arrow
Author (1)
Simone Alessandria
Simone Alessandria
author image
Simone Alessandria

Simone Alessandria wrote his first program when he was 12. It was a text-based fantasy game for the Commodore 64. Now, he is a trainer (MCT), author, speaker, passionate software architect, and always a proud coder. He is the founder and owner of Softwarehouseit. His mission is to help developers achieve more through training and mentoring. He has authored several books on Flutter, including Flutter Projects, published by Packt, and web courses on Pluralsight and Udemy.
Read more about Simone Alessandria

Right arrow

Creating basic container animations

In this recipe, you will place a square in the middle of the screen. When you click the IconButton in the AppBar, three animations will take place at the same time. The square will change color, size, and its top margin:

Shape  Description automatically generated

Figure 12.1: Example of AnimatedContainer

After following this recipe, you will understand how to work with the AnimatedContainer widget, one of the implicit animations, which allows the creation of simple animations with a Container.

Getting ready

In order to follow this recipe, create a new Flutter app, and call it my_animations.

How to do it...

In the following steps, you will create a new screen that shows an animation with an AnimatedContainer widget:

  1. Remove the MyHomePage class created in the sample app.
  2. Refactor the MyApp class as shown here:
    import 'package:flutter/material.dart';
    void main() {
      runApp(const MyApp());
    }
    class MyApp extends StatelessWidget...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Flutter Cookbook, Second Edition - Second Edition
Published in: May 2023Publisher: PacktISBN-13: 9781803245430

Author (1)

author image
Simone Alessandria

Simone Alessandria wrote his first program when he was 12. It was a text-based fantasy game for the Commodore 64. Now, he is a trainer (MCT), author, speaker, passionate software architect, and always a proud coder. He is the founder and owner of Softwarehouseit. His mission is to help developers achieve more through training and mentoring. He has authored several books on Flutter, including Flutter Projects, published by Packt, and web courses on Pluralsight and Udemy.
Read more about Simone Alessandria