From 9e7e6e7c9b3760b8e8e66eba3662896f87d943f1 Mon Sep 17 00:00:00 2001 From: matthew-carroll Date: Tue, 19 Jun 2018 00:58:03 +0000 Subject: [PATCH] =?UTF-8?q?Add=20docs=20to=20Opacity=20recommending=20Anim?= =?UTF-8?q?atedOpacity=20for=20opacity=20animatio=E2=80=A6=20(#18092)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add docs to Opacity recommending AnimatedOpacity for opacity animations (#15464) --- packages/flutter/lib/src/widgets/basic.dart | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index fbfce09348..7454b22674 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -143,11 +143,24 @@ class Directionality extends InheritedWidget { /// This is more efficient than adding and removing the child widget from the /// tree on demand. /// +/// ## Opacity Animation +/// +/// [Opacity] animations should be built using [AnimatedOpacity] rather than +/// manually rebuilding the [Opacity] widget. +/// +/// Animating an [Opacity] widget directly causes the widget (and possibly its +/// subtree) to rebuild each frame, which is not very efficient. Consider using +/// an [AnimatedOpacity] instead. +/// /// See also: /// /// * [ShaderMask], which can apply more elaborate effects to its child. /// * [Transform], which applies an arbitrary transform to its child widget at /// paint time. +/// * [AnimatedOpacity], which uses an animation internally to efficiently +/// animate opacity. +/// * [FadeTransition], which uses a provided animation to efficiently animate +/// opacity. class Opacity extends SingleChildRenderObjectWidget { /// Creates a widget that makes its child partially transparent. ///