From 08a23498c166aca9e026a8a45ef2e07eab388775 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Wed, 13 Apr 2022 13:24:06 -0700 Subject: [PATCH] Revert changes to opacity/fade transition repaint boundary and secondary change (#101844) --- packages/flutter/lib/src/widgets/basic.dart | 51 ++++--------------- .../lib/src/widgets/implicit_animations.dart | 4 +- .../flutter/lib/src/widgets/transitions.dart | 51 ++++--------------- .../flutter/test/cupertino/nav_bar_test.dart | 2 +- .../flutter/test/material/debug_test.dart | 4 -- 5 files changed, 22 insertions(+), 90 deletions(-) diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 6e202746716..d10c7f598d3 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -242,7 +242,7 @@ class Directionality extends InheritedWidget { /// opacity. /// * [Image], which can directly provide a partially transparent image with /// much less performance hit. -class Opacity extends StatelessWidget { +class Opacity extends SingleChildRenderObjectWidget { /// Creates a widget that makes its child partially transparent. /// /// The [opacity] argument must not be null and must be between 0.0 and 1.0 @@ -251,10 +251,10 @@ class Opacity extends StatelessWidget { Key? key, required this.opacity, this.alwaysIncludeSemantics = false, - this.child, + Widget? child, }) : assert(opacity != null && opacity >= 0.0 && opacity <= 1.0), assert(alwaysIncludeSemantics != null), - super(key: key); + super(key: key, child: child); /// The fraction to scale the child's alpha value. /// @@ -278,44 +278,6 @@ class Opacity extends StatelessWidget { /// would otherwise contribute relevant semantics. final bool alwaysIncludeSemantics; - /// The widget below this widget in the tree. - /// - /// {@macro flutter.widgets.ProxyWidget.child} - final Widget? child; - - @override - Widget build(BuildContext context) { - return _Opacity( - opacity: opacity, - alwaysIncludeSemantics: alwaysIncludeSemantics, - child: RepaintBoundary( - child: child, - ), - ); - } - - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties.add(DoubleProperty('opacity', opacity)); - properties.add(FlagProperty('alwaysIncludeSemantics', value: alwaysIncludeSemantics, ifTrue: 'alwaysIncludeSemantics')); - } -} - -/// The backing implementation of [Opacity]. -class _Opacity extends SingleChildRenderObjectWidget { - const _Opacity({ - Key? key, - required this.opacity, - this.alwaysIncludeSemantics = false, - Widget? child, - }) : assert(opacity != null && opacity >= 0.0 && opacity <= 1.0), - assert(alwaysIncludeSemantics != null), - super(key: key, child: child); - - final double opacity; - final bool alwaysIncludeSemantics; - @override RenderOpacity createRenderObject(BuildContext context) { return RenderOpacity( @@ -330,6 +292,13 @@ class _Opacity extends SingleChildRenderObjectWidget { ..opacity = opacity ..alwaysIncludeSemantics = alwaysIncludeSemantics; } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add(DoubleProperty('opacity', opacity)); + properties.add(FlagProperty('alwaysIncludeSemantics', value: alwaysIncludeSemantics, ifTrue: 'alwaysIncludeSemantics')); + } } /// A widget that applies a mask generated by a [Shader] to its child. diff --git a/packages/flutter/lib/src/widgets/implicit_animations.dart b/packages/flutter/lib/src/widgets/implicit_animations.dart index 3fe2aaa01ab..9fba1796142 100644 --- a/packages/flutter/lib/src/widgets/implicit_animations.dart +++ b/packages/flutter/lib/src/widgets/implicit_animations.dart @@ -1759,9 +1759,7 @@ class _AnimatedOpacityState extends ImplicitlyAnimatedWidgetState>('opacity', opacity)); - properties.add(FlagProperty('alwaysIncludeSemantics', value: alwaysIncludeSemantics, ifTrue: 'alwaysIncludeSemantics')); - } -} - -/// The backing implementation of a [FadeTransition]. -class _FadeTransition extends SingleChildRenderObjectWidget { - const _FadeTransition({ - Key? key, - required this.opacity, - this.alwaysIncludeSemantics = false, - Widget? child, - }) : assert(opacity != null), - super(key: key, child: child); - - final Animation opacity; - - final bool alwaysIncludeSemantics; - @override RenderAnimatedOpacity createRenderObject(BuildContext context) { return RenderAnimatedOpacity( @@ -601,6 +563,13 @@ class _FadeTransition extends SingleChildRenderObjectWidget { ..opacity = opacity ..alwaysIncludeSemantics = alwaysIncludeSemantics; } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add(DiagnosticsProperty>('opacity', opacity)); + properties.add(FlagProperty('alwaysIncludeSemantics', value: alwaysIncludeSemantics, ifTrue: 'alwaysIncludeSemantics')); + } } /// Animates the opacity of a sliver widget. diff --git a/packages/flutter/test/cupertino/nav_bar_test.dart b/packages/flutter/test/cupertino/nav_bar_test.dart index 7f118be616e..12ea7cb47dd 100644 --- a/packages/flutter/test/cupertino/nav_bar_test.dart +++ b/packages/flutter/test/cupertino/nav_bar_test.dart @@ -951,7 +951,7 @@ void main() { ); await expectLater( - find.byType(RepaintBoundary).first, + find.byType(RepaintBoundary).last, matchesGoldenFile('nav_bar_test.large_title.png'), ); }, diff --git a/packages/flutter/test/material/debug_test.dart b/packages/flutter/test/material/debug_test.dart index 83e89fd0074..605c9b1bb45 100644 --- a/packages/flutter/test/material/debug_test.dart +++ b/packages/flutter/test/material/debug_test.dart @@ -128,8 +128,6 @@ void main() { ' RepaintBoundary-[GlobalKey#00000]\n' ' IgnorePointer\n' ' AnimatedBuilder\n' - ' RepaintBoundary\n' - ' _FadeTransition\n' ' FadeTransition\n' ' FractionalTranslation\n' ' SlideTransition\n' @@ -304,8 +302,6 @@ void main() { ' MediaQuery\n' ' Padding\n' ' SafeArea\n' - ' RepaintBoundary\n' - ' _FadeTransition\n' ' FadeTransition\n' ' IconTheme\n' ' IconTheme\n'