Add stateful_widget_animation snippet template (#33295)
diff --git a/dev/snippets/config/templates/README.md b/dev/snippets/config/templates/README.md
index 8d7f260..5ae2e9c 100644
--- a/dev/snippets/config/templates/README.md
+++ b/dev/snippets/config/templates/README.md
@@ -86,3 +86,8 @@
- [`stateless_widget_scaffold`](stateless_widget_scaffold.tmpl) : Similar to
`stateless_widget_material`, except that it wraps the stateless widget with a
Scaffold.
+
+- [`stateful_widget_animation`](stateful_widget_animation.tmpl) : Similar to
+ `stateful_widget`, except that it declares an `AnimationController` instance
+ variable called `_controller`, and it properly initializes the controller
+ in `initState()` and properly disposes of the controller in `dispose()`.
diff --git a/dev/snippets/config/templates/stateful_widget_animation.tmpl b/dev/snippets/config/templates/stateful_widget_animation.tmpl
new file mode 100644
index 0000000..2e2b4a5
--- /dev/null
+++ b/dev/snippets/config/templates/stateful_widget_animation.tmpl
@@ -0,0 +1,53 @@
+// Flutter code sample for {{id}}
+
+{{description}}
+
+import 'package:flutter/widgets.dart';
+
+{{code-imports}}
+
+void main() => runApp(new MyApp());
+
+/// This Widget is the main application widget.
+class MyApp extends StatelessWidget {
+ @override
+ Widget build(BuildContext context) {
+ return WidgetsApp(
+ title: 'Flutter Code Sample',
+ home: MyStatefulWidget(),
+ color: const Color(0xffffffff),
+ );
+ }
+}
+
+{{code-preamble}}
+
+/// This is the stateful widget that the main application instantiates.
+class MyStatefulWidget extends StatefulWidget {
+ MyStatefulWidget({Key key}) : super(key: key);
+
+ @override
+ _MyStatefulWidgetState createState() => _MyStatefulWidgetState();
+}
+
+// This is the private State class that goes with MyStatefulWidget.
+class _MyStatefulWidgetState extends State<MyStatefulWidget> {
+ AnimationController _controller;
+
+ @override
+ void initState() {
+ super.initState();
+ _controller = AnimationController(
+ vsync: this,
+ duration: const Duration(seconds: 1),
+ );
+ }
+
+ @override
+ void dispose() {
+ _controller.dispose();
+ super.dispose();
+ }
+
+ {{code}}
+}