Make AnimatedSwitcher example into a dartpad example (#52547)
This commit is contained in:
parent
d444582f3e
commit
acd51a726e
@ -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].
|
||||||
|
///
|
||||||
|
/// {@tool dartpad --template=stateful_widget_material}
|
||||||
|
/// This sample shows a counter that animates the scale of a text widget
|
||||||
|
/// whenever the value changes.
|
||||||
///
|
///
|
||||||
/// ```dart
|
/// ```dart
|
||||||
/// class ClickCounter extends StatefulWidget {
|
/// int _count = 0;
|
||||||
/// const ClickCounter({Key key}) : super(key: key);
|
|
||||||
///
|
///
|
||||||
/// @override
|
/// @override
|
||||||
/// _ClickCounterState createState() => _ClickCounterState();
|
/// Widget build(BuildContext context) {
|
||||||
/// }
|
/// return Container(
|
||||||
///
|
/// color: Colors.white,
|
||||||
/// class _ClickCounterState extends State<ClickCounter> {
|
/// child: Column(
|
||||||
/// int _count = 0;
|
/// mainAxisAlignment: MainAxisAlignment.center,
|
||||||
///
|
/// children: <Widget>[
|
||||||
/// @override
|
/// AnimatedSwitcher(
|
||||||
/// Widget build(BuildContext context) {
|
/// duration: const Duration(milliseconds: 500),
|
||||||
/// return MaterialApp(
|
/// transitionBuilder: (Widget child, Animation<double> animation) {
|
||||||
/// home: Material(
|
/// return ScaleTransition(child: child, scale: animation);
|
||||||
/// child: Column(
|
/// },
|
||||||
/// mainAxisAlignment: MainAxisAlignment.center,
|
/// child: Text(
|
||||||
/// children: <Widget>[
|
/// '$_count',
|
||||||
/// AnimatedSwitcher(
|
/// // This key causes the AnimatedSwitcher to interpret this as a "new"
|
||||||
/// duration: const Duration(milliseconds: 500),
|
/// // child each time the count changes, so that it will begin its animation
|
||||||
/// transitionBuilder: (Widget child, Animation<double> animation) {
|
/// // when the count changes.
|
||||||
/// return ScaleTransition(child: child, scale: animation);
|
/// key: ValueKey<int>(_count),
|
||||||
/// },
|
/// style: Theme.of(context).textTheme.headline4,
|
||||||
/// child: Text(
|
/// ),
|
||||||
/// '$_count',
|
|
||||||
/// // This key causes the AnimatedSwitcher to interpret this as a "new"
|
|
||||||
/// // child each time the count changes, so that it will begin its animation
|
|
||||||
/// // when the count changes.
|
|
||||||
/// key: ValueKey<int>(_count),
|
|
||||||
/// style: Theme.of(context).textTheme.headline4,
|
|
||||||
/// ),
|
|
||||||
/// ),
|
|
||||||
/// RaisedButton(
|
|
||||||
/// child: const Text('Increment'),
|
|
||||||
/// onPressed: () {
|
|
||||||
/// setState(() {
|
|
||||||
/// _count += 1;
|
|
||||||
/// });
|
|
||||||
/// },
|
|
||||||
/// ),
|
|
||||||
/// ],
|
|
||||||
/// ),
|
/// ),
|
||||||
/// ),
|
/// RaisedButton(
|
||||||
/// );
|
/// child: const Text('Increment'),
|
||||||
/// }
|
/// onPressed: () {
|
||||||
|
/// setState(() {
|
||||||
|
/// _count += 1;
|
||||||
|
/// });
|
||||||
|
/// },
|
||||||
|
/// ),
|
||||||
|
/// ],
|
||||||
|
/// ),
|
||||||
|
/// );
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
/// {@end-tool}
|
/// {@end-tool}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user