Unverified Commit daa70608 authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Add stateful_widget_animation snippet template (#33295)

parent 9d520853
......@@ -86,3 +86,8 @@ follows:
- [`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()`.
// 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}}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment