diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 57a728b38e..f351027681 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -829,6 +829,8 @@ class ClipPath extends SingleChildRenderObjectWidget { /// /// See also: /// +/// * [AnimatedPhysicalModel], which animates property changes smoothly over +/// a given duration. /// * [DecoratedBox], which can apply more arbitrary shadow effects. /// * [ClipRect], which applies a clip to its child. class PhysicalModel extends SingleChildRenderObjectWidget { @@ -1075,6 +1077,11 @@ class Transform extends SingleChildRenderObjectWidget { /// ) /// ``` /// {@end-tool} + /// + /// See also: + /// + /// * [RotationTransition], which animates changes in rotation smoothly + /// over a given duration. Transform.rotate({ Key key, @required double angle, @@ -1138,6 +1145,11 @@ class Transform extends SingleChildRenderObjectWidget { /// ) /// ``` /// {@end-tool} + /// + /// See also: + /// + /// * [ScaleTransition], which animates changes in scale smoothly + /// over a given duration. Transform.scale({ Key key, @required double scale, @@ -1540,6 +1552,8 @@ class RotatedBox extends SingleChildRenderObjectWidget { /// /// See also: /// +/// * [AnimatedPadding], which animates changes in [padding] over a given +/// duration. /// * [EdgeInsets], the class that is used to describe the padding dimensions. /// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class Padding extends SingleChildRenderObjectWidget { @@ -1697,6 +1711,8 @@ class Padding extends SingleChildRenderObjectWidget { /// /// See also: /// +/// * [AnimatedAlign], which animates changes in [alignment] smoothly over a +/// given duration. /// * [CustomSingleChildLayout], which uses a delegate to control the layout of /// a single child. /// * [Center], which is the same as [Align] but with the [alignment] always @@ -3265,6 +3281,10 @@ class IndexedStack extends Stack { /// /// See also: /// +/// * [AnimatedPositioned], which automatically transitions the child's +/// position over a given duration whenever the given position changes. +/// * [PositionedTransition], which takes a provided [Animation] to transition +/// changes in the child's position over a given duration. /// * [PositionedDirectional], which adapts to the ambient [Directionality]. class Positioned extends ParentDataWidget { /// Creates a widget that controls where a child of a [Stack] is positioned. @@ -3531,6 +3551,9 @@ class Positioned extends ParentDataWidget { /// * [Positioned], which specifies the widget's position visually. /// * [Positioned.directional], which also specifies the widget's horizontal /// position using [start] and [end] but has an explicit [TextDirection]. +/// * [AnimatedPositionedDirectional], which automatically transitions +/// the child's position over a given duration whenever the given position +/// changes. class PositionedDirectional extends StatelessWidget { /// Creates a widget that controls where a child of a [Stack] is positioned. /// diff --git a/packages/flutter/lib/src/widgets/implicit_animations.dart b/packages/flutter/lib/src/widgets/implicit_animations.dart index 78da4db41f..9b2e2f3322 100644 --- a/packages/flutter/lib/src/widgets/implicit_animations.dart +++ b/packages/flutter/lib/src/widgets/implicit_animations.dart @@ -221,9 +221,51 @@ class TextStyleTween extends Tween { /// respond to those _changes_ by animating the changes over a specified /// [duration]. /// -/// Which properties are animated is left up to the subclass. Subclasses' States +/// Which properties are animated is left up to the subclass. Subclasses' [State]s /// must extend [ImplicitlyAnimatedWidgetState] and provide a way to visit the /// relevant fields to animate. +/// +/// ## Relationship to [AnimatedWidget]s +/// +/// [ImplicitlyAnimatedWidget]s (and their subclasses) automatically animate +/// changes in their properties whenever they change. For this, +/// they create and manage their own internal [AnimationController]s to power +/// the animation. While these widgets are simple to use and don't require you +/// to manually manage the lifecycle of an [AnimationController], they +/// are also somewhat limited: Besides the target value for the animated +/// property, developers can only chose a [duration] and [curve] for the +/// animation. If you require more control over the animation (e.g. you want +/// to stop it somewhere in the middle), consider using a +/// [AnimatedWidget] or one of its subclasses. These widget take an [Animation] +/// as an argument to power the animation. This gives the developer full control +/// over the animation at the cost of requiring you to manually manage the +/// underlying [AnimationController]. +/// +/// ## Common implicitly animated widgets +/// +/// A number of implicitly animated widgets ship with the framework. They are +/// usually named `AnimatedFoo`, where `Foo` is the name of the non-animated +/// version of that widget. Commonly used implicitly animated widgets include: +/// +/// * [AnimatedAlign], which is an implicitly animated version of [Align]. +/// * [AnimatedContainer], which is an implicitly animated version of +/// [Container]. +/// * [AnimatedDefaultTextStyle], which is an implicitly animated version of +/// [DefaultTextStyle]. +/// * [AnimatedOpacity], which is an implicitly animated version of [Opacity]. +/// * [AnimatedPadding], which is an implicitly animated version of [Padding]. +/// * [AnimatedPhysicalModel], which is an implicitly animated version of +/// [PhysicalModel]. +/// * [AnimatedPositioned], which is an implicitly animated version of +/// [Positioned]. +/// * [AnimatedPositionedDirectional], which is an implicitly animated version +/// of [PositionedDirectional]. +/// * [AnimatedTheme], which is an implicitly animated version of [Theme]. +/// * [AnimatedCrossFade], which cross-fades between two given children and +/// animates itself between their sizes. +/// * [AnimatedSize], which automatically transitions its size over a given +/// duration. +/// * [AnimatedSwitcher], which fades from one widget to another. abstract class ImplicitlyAnimatedWidget extends StatefulWidget { /// Initializes fields for subclasses. /// @@ -497,7 +539,7 @@ abstract class AnimatedWidgetBaseState exten } } -/// A container that gradually changes its values over a period of time. +/// Animated version of [Container] that gradually changes its values over a period of time. /// /// The [AnimatedContainer] will automatically animate between the old and /// new values of properties when they change using the provided curve and @@ -788,6 +830,14 @@ class _AnimatedPaddingState extends AnimatedWidgetBaseState { /// [Curves.fastOutSlowIn]. /// {@animation 250 266 https://flutter.github.io/assets-for-api-docs/assets/widgets/animated_align.mp4} /// +/// For the animation, you can chose a [curve] as well as a [duration] and the +/// widget will automatically animate to the new target [alignment]. If you require +/// more control over the animation (e.g. if you want to stop it mid-animation), +/// consider using an [AlignTransition] instead, which takes a provided +/// [Animation] as argument. While that allows you to fine-tune the animation, +/// it also requires more development overhead as you have to manually manage +/// the lifecycle of the underlying [AnimationController]. +/// /// See also: /// /// * [AnimatedContainer], which can transition more values at once. @@ -882,6 +932,14 @@ class _AnimatedAlignState extends AnimatedWidgetBaseState { /// of [Curves.fastOutSlowIn]. /// {@animation 250 266 https://flutter.github.io/assets-for-api-docs/assets/widgets/animated_positioned.mp4} /// +/// For the animation, you can chose a [curve] as well as a [duration] and the +/// widget will automatically animate to the new target position. If you require +/// more control over the animation (e.g. if you want to stop it mid-animation), +/// consider using an [PositionedTransition] instead, which takes a provided +/// [Animation] as argument. While that allows you to fine-tune the animation, +/// it also requires more development overhead as you have to manually manage +/// the lifecycle of the underlying [AnimationController]. +/// /// See also: /// /// * [AnimatedPositionedDirectional], which adapts to the ambient @@ -1272,6 +1330,14 @@ class _AnimatedOpacityState extends ImplicitlyAnimatedWidgetState { /// /// See also: /// +/// * [AnimatedPositioned], which transitions a child's position without +/// taking an explicit [Animation] argument. /// * [RelativePositionedTransition], a widget that transitions its child's /// position based on the value of a rectangle relative to a bounding box. /// * [SlideTransition], a widget that animates the position of a widget @@ -695,6 +733,8 @@ class DecoratedBoxTransition extends AnimatedWidget { /// /// See also: /// +/// * [AnimatedAlign], which animates changes to the [alignment] without +/// taking an explicit [Animation] argument. /// * [PositionedTransition], a widget that animates its child from a start /// position to an end position over the lifetime of the animation. /// * [RelativePositionedTransition], a widget that transitions its child's @@ -750,6 +790,8 @@ class AlignTransition extends AnimatedWidget { /// /// See also: /// +/// * [AnimatedDefaultTextStyle], which animates changes in text style without +/// taking an explicit [Animation] argument. /// * [DefaultTextStyle], which also defines a [TextStyle] for its descendants /// but is not animated. class DefaultTextStyleTransition extends AnimatedWidget {