Animate the properties of a container

Add a drawer to a screen

Fade a widget in and out

Cookbook

Animation

Fade a widget in and out

1. Create a box to fade in and out

2. Define a StatefulWidget

3. Display a button that toggles the visibility

4. Fade the box in and out

Interactive example

UI developers often need to show and hide elements on screen.
However, quickly popping elements on and off the screen can
feel jarring to end users. Instead,
fade elements in and out with an opacity animation to create
a smooth experience.

The AnimatedOpacity widget makes it easy to perform opacity
animations. This recipe uses the following steps:

Create a box to fade in and out.

Define a StatefulWidget.