From 97eaf58baafb0ac6576e475bc42749f6a4d70020 Mon Sep 17 00:00:00 2001 From: Anas35 <65850618+Anas35@users.noreply.github.com> Date: Mon, 2 Nov 2020 13:08:04 +0530 Subject: [PATCH] AnimatedPositioned (#69513) --- .../lib/src/widgets/implicit_animations.dart | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/packages/flutter/lib/src/widgets/implicit_animations.dart b/packages/flutter/lib/src/widgets/implicit_animations.dart index 3292a33f42..52c72ef052 100644 --- a/packages/flutter/lib/src/widgets/implicit_animations.dart +++ b/packages/flutter/lib/src/widgets/implicit_animations.dart @@ -1058,6 +1058,44 @@ class _AnimatedAlignState extends AnimatedWidgetBaseState { /// it also requires more development overhead as you have to manually manage /// the lifecycle of the underlying [AnimationController]. /// +/// {@tool dartpad --template=stateful_widget_scaffold} +/// +/// The following example transitions an AnimatedPositioned +/// between two states. It adjusts the `height`, `width`, and +/// [Positioned] properties when tapped. +/// +/// ```dart +/// bool selected = false; +/// +/// @override +/// Widget build(BuildContext context) { +/// return Stack( +/// children: [ +/// AnimatedPositioned( +/// width: selected ? 200.0 : 50.0, +/// height: selected ? 50.0 : 200.0, +/// top: selected ? 50.0 : 150.0, +/// right: 150.0, +/// duration: Duration(seconds: 2), +/// curve: Curves.fastOutSlowIn, +/// child: GestureDetector( +/// onTap: () { +/// setState(() { +/// selected = !selected; +/// }); +/// }, +/// child: Container( +/// color: Colors.blue, +/// child: Text('Tap me to start the animated transition'), +/// ), +/// ), +/// ), +/// ], +/// ); +/// } +///``` +/// {@end-tool} +/// /// See also: /// /// * [AnimatedPositionedDirectional], which adapts to the ambient