In the following steps, you will create a new screen that shows an animation with an AnimatedContainer widget:
- Create a new Flutter app and call it myanimations.
- Remove the MyHomePage class created in the sample app.
- Refactor the MyApp class as shown here:
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Animations Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyAnimation(),
);
}
}
- Create a file called my_animation.dart and add a new stateful widget called MyAnimation, using the stful shortcut. The result is shown here:
class MyAnimation extends StatefulWidget {
@override
_MyAnimationState createState() => _MyAnimationState();
}
class _MyAnimationState extends State<MyAnimation> {
@override
Widget build(BuildContext context) {
return Container()...