Unverified Commit acd51a72 authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Make AnimatedSwitcher example into a dartpad example (#52547)

parent d444582f
...@@ -87,53 +87,48 @@ typedef AnimatedSwitcherLayoutBuilder = Widget Function(Widget currentChild, Lis ...@@ -87,53 +87,48 @@ typedef AnimatedSwitcherLayoutBuilder = Widget Function(Widget currentChild, Lis
/// progress indicator and the image will be fading out while a new progress /// progress indicator and the image will be fading out while a new progress
/// indicator is fading in.) /// indicator is fading in.)
/// ///
/// {@tool snippet} /// The type of transition can be changed from a cross-fade to a custom
/// transition by setting the [transitionBuilder].
/// ///
/// ```dart /// {@tool dartpad --template=stateful_widget_material}
/// class ClickCounter extends StatefulWidget { /// This sample shows a counter that animates the scale of a text widget
/// const ClickCounter({Key key}) : super(key: key); /// whenever the value changes.
///
/// @override
/// _ClickCounterState createState() => _ClickCounterState();
/// }
/// ///
/// class _ClickCounterState extends State<ClickCounter> { /// ```dart
/// int _count = 0; /// int _count = 0;
/// ///
/// @override /// @override
/// Widget build(BuildContext context) { /// Widget build(BuildContext context) {
/// return MaterialApp( /// return Container(
/// home: Material( /// color: Colors.white,
/// child: Column( /// child: Column(
/// mainAxisAlignment: MainAxisAlignment.center, /// mainAxisAlignment: MainAxisAlignment.center,
/// children: <Widget>[ /// children: <Widget>[
/// AnimatedSwitcher( /// AnimatedSwitcher(
/// duration: const Duration(milliseconds: 500), /// duration: const Duration(milliseconds: 500),
/// transitionBuilder: (Widget child, Animation<double> animation) { /// transitionBuilder: (Widget child, Animation<double> animation) {
/// return ScaleTransition(child: child, scale: animation); /// return ScaleTransition(child: child, scale: animation);
/// }, /// },
/// child: Text( /// child: Text(
/// '$_count', /// '$_count',
/// // This key causes the AnimatedSwitcher to interpret this as a "new" /// // This key causes the AnimatedSwitcher to interpret this as a "new"
/// // child each time the count changes, so that it will begin its animation /// // child each time the count changes, so that it will begin its animation
/// // when the count changes. /// // when the count changes.
/// key: ValueKey<int>(_count), /// key: ValueKey<int>(_count),
/// style: Theme.of(context).textTheme.headline4, /// style: Theme.of(context).textTheme.headline4,
/// ), /// ),
/// ), /// ),
/// RaisedButton( /// RaisedButton(
/// child: const Text('Increment'), /// child: const Text('Increment'),
/// onPressed: () { /// onPressed: () {
/// setState(() { /// setState(() {
/// _count += 1; /// _count += 1;
/// }); /// });
/// }, /// },
/// ),
/// ],
/// ), /// ),
/// ), /// ],
/// ); /// ),
/// } /// );
/// } /// }
/// ``` /// ```
/// {@end-tool} /// {@end-tool}
......
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