In this recipe, you will build a widget that moves through the screen:
- In the lib folder, create a new file called shape_animation.dart.
- At the top of the file, import material.dart:
import 'package:flutter/material.dart';
- Create a new stateful widget using the stful shortcut, and call it ShapeAnimation. The result is shown here:
class ShapeAnimation extends StatefulWidget {
@override
_ShapeAnimationState createState() => _ShapeAnimationState();
}
class _ShapeAnimationState extends State<ShapeAnimation> {
@override
Widget build(BuildContext context) {
return Container(
);}}
- At the bottom of the shape_animation.dart file, create a stateless widget, using the stless shortcut, called Ball:
class Ball extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
);
}}
- In the build method of the Ball class, set the container so that it has a width and height of 100. Then, in its decoration, set the color to orange...