From 7948a7863bd8931e4e029c5b109f26c1b3dcf8ea Mon Sep 17 00:00:00 2001 From: Yuqian Li Date: Tue, 15 Sep 2020 11:27:07 -0700 Subject: [PATCH] Continue the clipBehavior breaking change (#61366) This follows https://github.com/flutter/flutter/pull/59364 and cl/319911104 FittedBox is still default to hardEdge clip as new FittedBox is added to Google very quickly. Let's first roll other part of changes into Google first. --- .../flutter/lib/src/cupertino/refresh.dart | 2 +- packages/flutter/lib/src/rendering/stack.dart | 14 -------- packages/flutter/lib/src/widgets/basic.dart | 36 +++++-------------- packages/flutter/test/widgets/basic_test.dart | 2 +- packages/flutter/test/widgets/flex_test.dart | 2 +- packages/flutter/test/widgets/stack_test.dart | 1 - packages/flutter/test/widgets/wrap_test.dart | 2 +- 7 files changed, 12 insertions(+), 47 deletions(-) diff --git a/packages/flutter/lib/src/cupertino/refresh.dart b/packages/flutter/lib/src/cupertino/refresh.dart index 0bc1e29a56..36d3df34f8 100644 --- a/packages/flutter/lib/src/cupertino/refresh.dart +++ b/packages/flutter/lib/src/cupertino/refresh.dart @@ -384,7 +384,7 @@ class CupertinoSliverRefreshControl extends StatefulWidget { // dragged widget, hence the use of Overflow.visible. return Center( child: Stack( - overflow: Overflow.visible, + clipBehavior: Clip.none, children: [ Positioned( top: _kActivityIndicatorMargin, diff --git a/packages/flutter/lib/src/rendering/stack.dart b/packages/flutter/lib/src/rendering/stack.dart index 3f27f4ee06..d7b4a6f297 100644 --- a/packages/flutter/lib/src/rendering/stack.dart +++ b/packages/flutter/lib/src/rendering/stack.dart @@ -268,20 +268,6 @@ enum StackFit { passthrough, } -// TODO(liyuqian): Deprecate and remove `Overflow` once its usages are removed from Google. - -/// Whether overflowing children should be clipped, or their overflow be -/// visible. -enum Overflow { - /// Overflowing children will be visible. - /// - /// The visible overflow area will not accept hit testing. - visible, - - /// Overflowing children will be clipped to the bounds of their parent. - clip, -} - /// Implements the stack layout algorithm. /// /// In a stack layout, the children are positioned on top of each other in the diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 3ab18d579f..e443c119b3 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -41,7 +41,6 @@ export 'package:flutter/rendering.dart' show LayerLink, MainAxisAlignment, MainAxisSize, - Overflow, MultiChildLayoutDelegate, PaintingContext, PointerCancelEvent, @@ -1485,7 +1484,6 @@ class FittedBox extends SingleChildRenderObjectWidget { /// relative to text direction. final AlignmentGeometry alignment; - // TODO(liyuqian): defaults to [Clip.none] once Google references are updated. /// {@macro flutter.widgets.Clip} /// /// Defaults to [Clip.hardEdge]. @@ -2291,7 +2289,7 @@ class UnconstrainedBox extends SingleChildRenderObjectWidget { this.textDirection, this.alignment = Alignment.center, this.constrainedAxis, - this.clipBehavior = Clip.hardEdge, + this.clipBehavior = Clip.none, }) : assert(alignment != null), assert(clipBehavior != null), super(key: key, child: child); @@ -2319,10 +2317,9 @@ class UnconstrainedBox extends SingleChildRenderObjectWidget { /// will be retained. final Axis? constrainedAxis; - // TODO(liyuqian): defaults to [Clip.none] once Google references are updated. /// {@macro flutter.widgets.Clip} /// - /// Defaults to [Clip.hardEdge]. + /// Defaults to [Clip.none]. final Clip clipBehavior; @override @@ -3313,7 +3310,6 @@ class Stack extends MultiChildRenderObjectWidget { this.alignment = AlignmentDirectional.topStart, this.textDirection, this.fit = StackFit.loose, - this.overflow = Overflow.clip, this.clipBehavior = Clip.hardEdge, List children = const [], }) : assert(clipBehavior != null), @@ -3354,20 +3350,6 @@ class Stack extends MultiChildRenderObjectWidget { /// ([StackFit.expand]). final StackFit fit; - // TODO(liyuqian): Deprecate and remove [overflow] once its usages are removed from Google. - - /// Whether overflowing children should be clipped. See [Overflow]. - /// - /// Some children in a stack might overflow its box. When this flag is set to - /// [Overflow.clip], children cannot paint outside of the stack's box. - /// - /// When set to [Overflow.visible], the visible overflow area will not accept - /// hit testing. - /// - /// This overrides [clipBehavior] for now due to a staged roll out without - /// breaking Google. We will remove it and only use [clipBehavior] soon. - final Overflow overflow; - /// {@macro flutter.widgets.Clip} /// /// Defaults to [Clip.hardEdge]. @@ -3392,7 +3374,7 @@ class Stack extends MultiChildRenderObjectWidget { alignment: alignment, textDirection: textDirection ?? Directionality.of(context), fit: fit, - clipBehavior: overflow == Overflow.visible ? Clip.none : clipBehavior, + clipBehavior: clipBehavior, ); } @@ -3403,7 +3385,7 @@ class Stack extends MultiChildRenderObjectWidget { ..alignment = alignment ..textDirection = textDirection ?? Directionality.of(context) ..fit = fit - ..clipBehavior = overflow == Overflow.visible ? Clip.none : clipBehavior; + ..clipBehavior = clipBehavior; } @override @@ -3940,7 +3922,7 @@ class Flex extends MultiChildRenderObjectWidget { this.textDirection, this.verticalDirection = VerticalDirection.down, this.textBaseline = TextBaseline.alphabetic, - this.clipBehavior = Clip.hardEdge, + this.clipBehavior = Clip.none, List children = const [], }) : assert(direction != null), assert(mainAxisAlignment != null), @@ -4040,10 +4022,9 @@ class Flex extends MultiChildRenderObjectWidget { /// Defaults to [TextBaseline.alphabetic]. final TextBaseline? textBaseline; - // TODO(liyuqian): defaults to [Clip.none] once Google references are updated. /// {@macro flutter.widgets.Clip} /// - /// Defaults to [Clip.hardEdge]. + /// Defaults to [Clip.none]. final Clip clipBehavior; bool get _needTextDirection { @@ -4795,7 +4776,7 @@ class Wrap extends MultiChildRenderObjectWidget { this.crossAxisAlignment = WrapCrossAlignment.start, this.textDirection, this.verticalDirection = VerticalDirection.down, - this.clipBehavior = Clip.hardEdge, + this.clipBehavior = Clip.none, List children = const [], }) : assert(clipBehavior != null), super(key: key, children: children); @@ -4931,10 +4912,9 @@ class Wrap extends MultiChildRenderObjectWidget { /// [verticalDirection] must not be null. final VerticalDirection verticalDirection; - // TODO(liyuqian): defaults to [Clip.none] once Google references are updated. /// {@macro flutter.widgets.Clip} /// - /// Defaults to [Clip.hardEdge]. + /// Defaults to [Clip.none]. final Clip clipBehavior; @override diff --git a/packages/flutter/test/widgets/basic_test.dart b/packages/flutter/test/widgets/basic_test.dart index 2a534afde7..d4a675b901 100644 --- a/packages/flutter/test/widgets/basic_test.dart +++ b/packages/flutter/test/widgets/basic_test.dart @@ -340,7 +340,7 @@ void main() { testWidgets('UnconstrainedBox can set and update clipBehavior', (WidgetTester tester) async { await tester.pumpWidget(const UnconstrainedBox()); final RenderUnconstrainedBox renderObject = tester.allRenderObjects.whereType().first; - expect(renderObject.clipBehavior, equals(Clip.hardEdge)); + expect(renderObject.clipBehavior, equals(Clip.none)); await tester.pumpWidget(const UnconstrainedBox(clipBehavior: Clip.antiAlias)); expect(renderObject.clipBehavior, equals(Clip.antiAlias)); diff --git a/packages/flutter/test/widgets/flex_test.dart b/packages/flutter/test/widgets/flex_test.dart index aaa9a10783..b6b15e9c8f 100644 --- a/packages/flutter/test/widgets/flex_test.dart +++ b/packages/flutter/test/widgets/flex_test.dart @@ -146,7 +146,7 @@ void main() { testWidgets('Can set and update clipBehavior', (WidgetTester tester) async { await tester.pumpWidget(Flex(direction: Axis.vertical)); final RenderFlex renderObject = tester.allRenderObjects.whereType().first; - expect(renderObject.clipBehavior, equals(Clip.hardEdge)); + expect(renderObject.clipBehavior, equals(Clip.none)); await tester.pumpWidget(Flex(direction: Axis.vertical, clipBehavior: Clip.antiAlias)); expect(renderObject.clipBehavior, equals(Clip.antiAlias)); diff --git a/packages/flutter/test/widgets/stack_test.dart b/packages/flutter/test/widgets/stack_test.dart index 9c7f430381..b676f5dda8 100644 --- a/packages/flutter/test/widgets/stack_test.dart +++ b/packages/flutter/test/widgets/stack_test.dart @@ -453,7 +453,6 @@ void main() { textDirection: TextDirection.ltr, child: Center( child: Stack( - overflow: Overflow.visible, clipBehavior: Clip.none, children: const [ SizedBox( diff --git a/packages/flutter/test/widgets/wrap_test.dart b/packages/flutter/test/widgets/wrap_test.dart index 9fce127430..0ceefa6dde 100644 --- a/packages/flutter/test/widgets/wrap_test.dart +++ b/packages/flutter/test/widgets/wrap_test.dart @@ -902,7 +902,7 @@ void main() { testWidgets('Wrap can set and update clipBehavior', (WidgetTester tester) async { await tester.pumpWidget(Wrap(textDirection: TextDirection.ltr)); final RenderWrap renderObject = tester.allRenderObjects.whereType().first; - expect(renderObject.clipBehavior, equals(Clip.hardEdge)); + expect(renderObject.clipBehavior, equals(Clip.none)); await tester.pumpWidget(Wrap(textDirection: TextDirection.ltr, clipBehavior: Clip.antiAlias)); expect(renderObject.clipBehavior, equals(Clip.antiAlias));