chapter six
In this chapter:
- Using the AnimatedWidget
- Using the canvas and CustomPaint class
- The Paint class
- AnimationControllers, Tweens, and Tickers
- TweenSequence class
- SlideTransition and other convenience widgets
The built-in widgets you’ve seen so far are all about building a structural interface with Flutter. In this chapter, we’ll explore a couple new widgets to create custom animations, as well as look at the the canvas widget. These widgets are used to tell Flutter exactly what we want it to paint on the screen. In particular, we’ll look at two things:
- Animations. In the weather app, almost every display widget on the screen will animate in some way. All the text will change color, all the background objects will change color and move around the screen, and the icons will change shape and color. The most interesting note here is that the app will still be buttery smooth, despite changing entirely with almost every interaction from a user.
The bulk of the logic needed to build these animations is in theforecast_page, and a couple methods are in theforecast_controller. We’ll cover most of that in the next section. That section is going to be about animating theSunclass, from start to finish.
- The canvas. I’m going to make that cloud shape in the background from scratch, using the
Canvas. The canvas is a widget that allows you to tell Flutter what to draw, pixel by pixel. It requires math, and it’s fun.