Unverified Commit e6dc6a8b authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Animation API doc improvments (#35919)

parent 8bcbc45e
......@@ -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<Stack> {
/// Creates a widget that controls where a child of a [Stack] is positioned.
......@@ -3531,6 +3551,9 @@ class Positioned extends ParentDataWidget<Stack> {
/// * [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.
///
......
......@@ -221,9 +221,51 @@ class TextStyleTween extends Tween<TextStyle> {
/// 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<T extends ImplicitlyAnimatedWidget> 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<AnimatedPadding> {
/// [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<AnimatedAlign> {
/// 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<AnimatedOpacit
/// Here's an illustration of what using this widget looks like, using a [curve]
/// of [Curves.elasticInOut].
/// {@animation 250 266 https://flutter.github.io/assets-for-api-docs/assets/widgets/animated_default_text_style.mp4}
///
/// For the animation, you can chose a [curve] as well as a [duration] and the
/// widget will automatically animate to the new default text style. If you require
/// more control over the animation (e.g. if you want to stop it mid-animation),
/// consider using an [DefaultTextStyleTransition] 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].
class AnimatedDefaultTextStyle extends ImplicitlyAnimatedWidget {
/// Creates a widget that animates the default text style implicitly.
///
......
......@@ -13,6 +13,13 @@ import 'media_query.dart';
// String _name;
/// The text style to apply to descendant [Text] widgets without explicit style.
///
/// See also:
///
/// * [AnimatedDefaultTextStyle], which animates changes in the text style
/// smoothly over a given duration.
/// * [DefaultTextStyleTransition], which takes a provided [Animation] to
/// animate changes in text style smoothly over time.
class DefaultTextStyle extends InheritedWidget {
/// Creates a default text style for the given subtree.
///
......
......@@ -78,13 +78,43 @@ export 'package:flutter/rendering.dart' show RelativeRect;
/// For more complex case involving additional state, consider using
/// [AnimatedBuilder].
///
/// See also:
///
/// * [AnimatedBuilder], which is useful for more complex use cases.
/// * [Animation], which is a [Listenable] object that can be used for
/// [listenable].
/// * [ChangeNotifier], which is another [Listenable] object that can be used
/// for [listenable].
/// ## Relationship to [ImplicitlyAnimatedWidget]s
///
/// [AnimatedWidget]s (and their subclasses) take an explicit [Listenable] as
/// argument, which is usually an [Animation] derived from an
/// [AnimationController]. In most cases, the lifecycle of that
/// [AnimationController] has to be managed manually by the developer.
/// In contrast to that, [ImplicitlyAnimatedWidget]s (and their subclasses)
/// automatically manage their own internal [AnimationController] making those
/// classes easier to use as no external [Animation] has to be provided by the
/// developer. If you only need to set a target value for the animation and
/// configure its duration/curve, consider using (a subclass of)
/// [ImplicitlyAnimatedWidget]s instead of (a subclass of) this class.
///
/// ## Common animated widgets
///
/// A number of animated widgets ship with the framework. They are usually named
/// `FooTransition`, where `Foo` is the name of the non-animated
/// version of that widget. The subclasses of this class should not be confused
/// with subclasses of [ImplicitlyAnimatedWidget] (see above), which are usually
/// named `AnimatedFoo`. Commonly used animated widgets include:
///
/// * [AnimatedBuilder], which is useful for complex animation use cases and a
/// notable exception to the naming scheme of [AnimatedWidget] subclasses.
/// * [AlignTransition], which is an animated version of [Align].
/// * [DecoratedBoxTransition], which is an animated version of [DecoratedBox].
/// * [DefaultTextStyleTransition], which is an animated version of
/// [DefaultTextStyle].
/// * [PositionedTransition], which is an animated version of [Positioned].
/// * [RelativePositionedTransition], which is an animated version of
/// [Positioned].
/// * [RotationTransition], which animates the rotation of a widget.
/// * [ScaleTransition], which animates the scale of a widget.
/// * [SizeTransition], which animates its own size.
/// * [SlideTransition], which animates the position of a widget relative to
/// its normal position.
/// * [FadeTransition], which is an animated version of [Opacity].
/// * [AnimatedModalBarrier], which is an animated version of [ModalBarrier].
abstract class AnimatedWidget extends StatefulWidget {
/// Creates a widget that rebuilds when the given listenable changes.
///
......@@ -446,6 +476,12 @@ class SizeTransition extends AnimatedWidget {
/// Here's an illustration of the [FadeTransition] widget, with it's [opacity]
/// animated by a [CurvedAnimation] set to [Curves.fastOutSlowIn]:
/// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/fade_transition.mp4}
///
/// See also:
///
/// * [Opacity], which does not animate changes in opacity.
/// * [AnimatedOpacity], which animates changes in opacity without taking an
/// explicit [Animation] argument.
class FadeTransition extends SingleChildRenderObjectWidget {
/// Creates an opacity transition.
///
......@@ -530,6 +566,8 @@ class RelativeRectTween extends Tween<RelativeRect> {
///
/// 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 {
......
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