Unverified Commit 7948a786 authored by Yuqian Li's avatar Yuqian Li Committed by GitHub

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.
parent f52380b6
...@@ -384,7 +384,7 @@ class CupertinoSliverRefreshControl extends StatefulWidget { ...@@ -384,7 +384,7 @@ class CupertinoSliverRefreshControl extends StatefulWidget {
// dragged widget, hence the use of Overflow.visible. // dragged widget, hence the use of Overflow.visible.
return Center( return Center(
child: Stack( child: Stack(
overflow: Overflow.visible, clipBehavior: Clip.none,
children: <Widget>[ children: <Widget>[
Positioned( Positioned(
top: _kActivityIndicatorMargin, top: _kActivityIndicatorMargin,
......
...@@ -268,20 +268,6 @@ enum StackFit { ...@@ -268,20 +268,6 @@ enum StackFit {
passthrough, 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. /// Implements the stack layout algorithm.
/// ///
/// In a stack layout, the children are positioned on top of each other in the /// In a stack layout, the children are positioned on top of each other in the
......
...@@ -41,7 +41,6 @@ export 'package:flutter/rendering.dart' show ...@@ -41,7 +41,6 @@ export 'package:flutter/rendering.dart' show
LayerLink, LayerLink,
MainAxisAlignment, MainAxisAlignment,
MainAxisSize, MainAxisSize,
Overflow,
MultiChildLayoutDelegate, MultiChildLayoutDelegate,
PaintingContext, PaintingContext,
PointerCancelEvent, PointerCancelEvent,
...@@ -1485,7 +1484,6 @@ class FittedBox extends SingleChildRenderObjectWidget { ...@@ -1485,7 +1484,6 @@ class FittedBox extends SingleChildRenderObjectWidget {
/// relative to text direction. /// relative to text direction.
final AlignmentGeometry alignment; final AlignmentGeometry alignment;
// TODO(liyuqian): defaults to [Clip.none] once Google references are updated.
/// {@macro flutter.widgets.Clip} /// {@macro flutter.widgets.Clip}
/// ///
/// Defaults to [Clip.hardEdge]. /// Defaults to [Clip.hardEdge].
...@@ -2291,7 +2289,7 @@ class UnconstrainedBox extends SingleChildRenderObjectWidget { ...@@ -2291,7 +2289,7 @@ class UnconstrainedBox extends SingleChildRenderObjectWidget {
this.textDirection, this.textDirection,
this.alignment = Alignment.center, this.alignment = Alignment.center,
this.constrainedAxis, this.constrainedAxis,
this.clipBehavior = Clip.hardEdge, this.clipBehavior = Clip.none,
}) : assert(alignment != null), }) : assert(alignment != null),
assert(clipBehavior != null), assert(clipBehavior != null),
super(key: key, child: child); super(key: key, child: child);
...@@ -2319,10 +2317,9 @@ class UnconstrainedBox extends SingleChildRenderObjectWidget { ...@@ -2319,10 +2317,9 @@ class UnconstrainedBox extends SingleChildRenderObjectWidget {
/// will be retained. /// will be retained.
final Axis? constrainedAxis; final Axis? constrainedAxis;
// TODO(liyuqian): defaults to [Clip.none] once Google references are updated.
/// {@macro flutter.widgets.Clip} /// {@macro flutter.widgets.Clip}
/// ///
/// Defaults to [Clip.hardEdge]. /// Defaults to [Clip.none].
final Clip clipBehavior; final Clip clipBehavior;
@override @override
...@@ -3313,7 +3310,6 @@ class Stack extends MultiChildRenderObjectWidget { ...@@ -3313,7 +3310,6 @@ class Stack extends MultiChildRenderObjectWidget {
this.alignment = AlignmentDirectional.topStart, this.alignment = AlignmentDirectional.topStart,
this.textDirection, this.textDirection,
this.fit = StackFit.loose, this.fit = StackFit.loose,
this.overflow = Overflow.clip,
this.clipBehavior = Clip.hardEdge, this.clipBehavior = Clip.hardEdge,
List<Widget> children = const <Widget>[], List<Widget> children = const <Widget>[],
}) : assert(clipBehavior != null), }) : assert(clipBehavior != null),
...@@ -3354,20 +3350,6 @@ class Stack extends MultiChildRenderObjectWidget { ...@@ -3354,20 +3350,6 @@ class Stack extends MultiChildRenderObjectWidget {
/// ([StackFit.expand]). /// ([StackFit.expand]).
final StackFit fit; 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} /// {@macro flutter.widgets.Clip}
/// ///
/// Defaults to [Clip.hardEdge]. /// Defaults to [Clip.hardEdge].
...@@ -3392,7 +3374,7 @@ class Stack extends MultiChildRenderObjectWidget { ...@@ -3392,7 +3374,7 @@ class Stack extends MultiChildRenderObjectWidget {
alignment: alignment, alignment: alignment,
textDirection: textDirection ?? Directionality.of(context), textDirection: textDirection ?? Directionality.of(context),
fit: fit, fit: fit,
clipBehavior: overflow == Overflow.visible ? Clip.none : clipBehavior, clipBehavior: clipBehavior,
); );
} }
...@@ -3403,7 +3385,7 @@ class Stack extends MultiChildRenderObjectWidget { ...@@ -3403,7 +3385,7 @@ class Stack extends MultiChildRenderObjectWidget {
..alignment = alignment ..alignment = alignment
..textDirection = textDirection ?? Directionality.of(context) ..textDirection = textDirection ?? Directionality.of(context)
..fit = fit ..fit = fit
..clipBehavior = overflow == Overflow.visible ? Clip.none : clipBehavior; ..clipBehavior = clipBehavior;
} }
@override @override
...@@ -3940,7 +3922,7 @@ class Flex extends MultiChildRenderObjectWidget { ...@@ -3940,7 +3922,7 @@ class Flex extends MultiChildRenderObjectWidget {
this.textDirection, this.textDirection,
this.verticalDirection = VerticalDirection.down, this.verticalDirection = VerticalDirection.down,
this.textBaseline = TextBaseline.alphabetic, this.textBaseline = TextBaseline.alphabetic,
this.clipBehavior = Clip.hardEdge, this.clipBehavior = Clip.none,
List<Widget> children = const <Widget>[], List<Widget> children = const <Widget>[],
}) : assert(direction != null), }) : assert(direction != null),
assert(mainAxisAlignment != null), assert(mainAxisAlignment != null),
...@@ -4040,10 +4022,9 @@ class Flex extends MultiChildRenderObjectWidget { ...@@ -4040,10 +4022,9 @@ class Flex extends MultiChildRenderObjectWidget {
/// Defaults to [TextBaseline.alphabetic]. /// Defaults to [TextBaseline.alphabetic].
final TextBaseline? textBaseline; final TextBaseline? textBaseline;
// TODO(liyuqian): defaults to [Clip.none] once Google references are updated.
/// {@macro flutter.widgets.Clip} /// {@macro flutter.widgets.Clip}
/// ///
/// Defaults to [Clip.hardEdge]. /// Defaults to [Clip.none].
final Clip clipBehavior; final Clip clipBehavior;
bool get _needTextDirection { bool get _needTextDirection {
...@@ -4795,7 +4776,7 @@ class Wrap extends MultiChildRenderObjectWidget { ...@@ -4795,7 +4776,7 @@ class Wrap extends MultiChildRenderObjectWidget {
this.crossAxisAlignment = WrapCrossAlignment.start, this.crossAxisAlignment = WrapCrossAlignment.start,
this.textDirection, this.textDirection,
this.verticalDirection = VerticalDirection.down, this.verticalDirection = VerticalDirection.down,
this.clipBehavior = Clip.hardEdge, this.clipBehavior = Clip.none,
List<Widget> children = const <Widget>[], List<Widget> children = const <Widget>[],
}) : assert(clipBehavior != null), super(key: key, children: children); }) : assert(clipBehavior != null), super(key: key, children: children);
...@@ -4931,10 +4912,9 @@ class Wrap extends MultiChildRenderObjectWidget { ...@@ -4931,10 +4912,9 @@ class Wrap extends MultiChildRenderObjectWidget {
/// [verticalDirection] must not be null. /// [verticalDirection] must not be null.
final VerticalDirection verticalDirection; final VerticalDirection verticalDirection;
// TODO(liyuqian): defaults to [Clip.none] once Google references are updated.
/// {@macro flutter.widgets.Clip} /// {@macro flutter.widgets.Clip}
/// ///
/// Defaults to [Clip.hardEdge]. /// Defaults to [Clip.none].
final Clip clipBehavior; final Clip clipBehavior;
@override @override
......
...@@ -340,7 +340,7 @@ void main() { ...@@ -340,7 +340,7 @@ void main() {
testWidgets('UnconstrainedBox can set and update clipBehavior', (WidgetTester tester) async { testWidgets('UnconstrainedBox can set and update clipBehavior', (WidgetTester tester) async {
await tester.pumpWidget(const UnconstrainedBox()); await tester.pumpWidget(const UnconstrainedBox());
final RenderUnconstrainedBox renderObject = tester.allRenderObjects.whereType<RenderUnconstrainedBox>().first; final RenderUnconstrainedBox renderObject = tester.allRenderObjects.whereType<RenderUnconstrainedBox>().first;
expect(renderObject.clipBehavior, equals(Clip.hardEdge)); expect(renderObject.clipBehavior, equals(Clip.none));
await tester.pumpWidget(const UnconstrainedBox(clipBehavior: Clip.antiAlias)); await tester.pumpWidget(const UnconstrainedBox(clipBehavior: Clip.antiAlias));
expect(renderObject.clipBehavior, equals(Clip.antiAlias)); expect(renderObject.clipBehavior, equals(Clip.antiAlias));
......
...@@ -146,7 +146,7 @@ void main() { ...@@ -146,7 +146,7 @@ void main() {
testWidgets('Can set and update clipBehavior', (WidgetTester tester) async { testWidgets('Can set and update clipBehavior', (WidgetTester tester) async {
await tester.pumpWidget(Flex(direction: Axis.vertical)); await tester.pumpWidget(Flex(direction: Axis.vertical));
final RenderFlex renderObject = tester.allRenderObjects.whereType<RenderFlex>().first; final RenderFlex renderObject = tester.allRenderObjects.whereType<RenderFlex>().first;
expect(renderObject.clipBehavior, equals(Clip.hardEdge)); expect(renderObject.clipBehavior, equals(Clip.none));
await tester.pumpWidget(Flex(direction: Axis.vertical, clipBehavior: Clip.antiAlias)); await tester.pumpWidget(Flex(direction: Axis.vertical, clipBehavior: Clip.antiAlias));
expect(renderObject.clipBehavior, equals(Clip.antiAlias)); expect(renderObject.clipBehavior, equals(Clip.antiAlias));
......
...@@ -453,7 +453,6 @@ void main() { ...@@ -453,7 +453,6 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Center( child: Center(
child: Stack( child: Stack(
overflow: Overflow.visible,
clipBehavior: Clip.none, clipBehavior: Clip.none,
children: const <Widget>[ children: const <Widget>[
SizedBox( SizedBox(
......
...@@ -902,7 +902,7 @@ void main() { ...@@ -902,7 +902,7 @@ void main() {
testWidgets('Wrap can set and update clipBehavior', (WidgetTester tester) async { testWidgets('Wrap can set and update clipBehavior', (WidgetTester tester) async {
await tester.pumpWidget(Wrap(textDirection: TextDirection.ltr)); await tester.pumpWidget(Wrap(textDirection: TextDirection.ltr));
final RenderWrap renderObject = tester.allRenderObjects.whereType<RenderWrap>().first; final RenderWrap renderObject = tester.allRenderObjects.whereType<RenderWrap>().first;
expect(renderObject.clipBehavior, equals(Clip.hardEdge)); expect(renderObject.clipBehavior, equals(Clip.none));
await tester.pumpWidget(Wrap(textDirection: TextDirection.ltr, clipBehavior: Clip.antiAlias)); await tester.pumpWidget(Wrap(textDirection: TextDirection.ltr, clipBehavior: Clip.antiAlias));
expect(renderObject.clipBehavior, equals(Clip.antiAlias)); expect(renderObject.clipBehavior, equals(Clip.antiAlias));
......
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