Skip to content

Commit 7948a78

Browse files
authored
Continue the clipBehavior breaking change (#61366)
This follows #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.
1 parent f52380b commit 7948a78

File tree

7 files changed

+12
-47
lines changed

7 files changed

+12
-47
lines changed

packages/flutter/lib/src/cupertino/refresh.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ class CupertinoSliverRefreshControl extends StatefulWidget {
384384
// dragged widget, hence the use of Overflow.visible.
385385
return Center(
386386
child: Stack(
387-
overflow: Overflow.visible,
387+
clipBehavior: Clip.none,
388388
children: <Widget>[
389389
Positioned(
390390
top: _kActivityIndicatorMargin,

packages/flutter/lib/src/rendering/stack.dart

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -268,20 +268,6 @@ enum StackFit {
268268
passthrough,
269269
}
270270

271-
// TODO(liyuqian): Deprecate and remove `Overflow` once its usages are removed from Google.
272-
273-
/// Whether overflowing children should be clipped, or their overflow be
274-
/// visible.
275-
enum Overflow {
276-
/// Overflowing children will be visible.
277-
///
278-
/// The visible overflow area will not accept hit testing.
279-
visible,
280-
281-
/// Overflowing children will be clipped to the bounds of their parent.
282-
clip,
283-
}
284-
285271
/// Implements the stack layout algorithm.
286272
///
287273
/// In a stack layout, the children are positioned on top of each other in the

packages/flutter/lib/src/widgets/basic.dart

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ export 'package:flutter/rendering.dart' show
4141
LayerLink,
4242
MainAxisAlignment,
4343
MainAxisSize,
44-
Overflow,
4544
MultiChildLayoutDelegate,
4645
PaintingContext,
4746
PointerCancelEvent,
@@ -1485,7 +1484,6 @@ class FittedBox extends SingleChildRenderObjectWidget {
14851484
/// relative to text direction.
14861485
final AlignmentGeometry alignment;
14871486

1488-
// TODO(liyuqian): defaults to [Clip.none] once Google references are updated.
14891487
/// {@macro flutter.widgets.Clip}
14901488
///
14911489
/// Defaults to [Clip.hardEdge].
@@ -2291,7 +2289,7 @@ class UnconstrainedBox extends SingleChildRenderObjectWidget {
22912289
this.textDirection,
22922290
this.alignment = Alignment.center,
22932291
this.constrainedAxis,
2294-
this.clipBehavior = Clip.hardEdge,
2292+
this.clipBehavior = Clip.none,
22952293
}) : assert(alignment != null),
22962294
assert(clipBehavior != null),
22972295
super(key: key, child: child);
@@ -2319,10 +2317,9 @@ class UnconstrainedBox extends SingleChildRenderObjectWidget {
23192317
/// will be retained.
23202318
final Axis? constrainedAxis;
23212319

2322-
// TODO(liyuqian): defaults to [Clip.none] once Google references are updated.
23232320
/// {@macro flutter.widgets.Clip}
23242321
///
2325-
/// Defaults to [Clip.hardEdge].
2322+
/// Defaults to [Clip.none].
23262323
final Clip clipBehavior;
23272324

23282325
@override
@@ -3313,7 +3310,6 @@ class Stack extends MultiChildRenderObjectWidget {
33133310
this.alignment = AlignmentDirectional.topStart,
33143311
this.textDirection,
33153312
this.fit = StackFit.loose,
3316-
this.overflow = Overflow.clip,
33173313
this.clipBehavior = Clip.hardEdge,
33183314
List<Widget> children = const <Widget>[],
33193315
}) : assert(clipBehavior != null),
@@ -3354,20 +3350,6 @@ class Stack extends MultiChildRenderObjectWidget {
33543350
/// ([StackFit.expand]).
33553351
final StackFit fit;
33563352

3357-
// TODO(liyuqian): Deprecate and remove [overflow] once its usages are removed from Google.
3358-
3359-
/// Whether overflowing children should be clipped. See [Overflow].
3360-
///
3361-
/// Some children in a stack might overflow its box. When this flag is set to
3362-
/// [Overflow.clip], children cannot paint outside of the stack's box.
3363-
///
3364-
/// When set to [Overflow.visible], the visible overflow area will not accept
3365-
/// hit testing.
3366-
///
3367-
/// This overrides [clipBehavior] for now due to a staged roll out without
3368-
/// breaking Google. We will remove it and only use [clipBehavior] soon.
3369-
final Overflow overflow;
3370-
33713353
/// {@macro flutter.widgets.Clip}
33723354
///
33733355
/// Defaults to [Clip.hardEdge].
@@ -3392,7 +3374,7 @@ class Stack extends MultiChildRenderObjectWidget {
33923374
alignment: alignment,
33933375
textDirection: textDirection ?? Directionality.of(context),
33943376
fit: fit,
3395-
clipBehavior: overflow == Overflow.visible ? Clip.none : clipBehavior,
3377+
clipBehavior: clipBehavior,
33963378
);
33973379
}
33983380

@@ -3403,7 +3385,7 @@ class Stack extends MultiChildRenderObjectWidget {
34033385
..alignment = alignment
34043386
..textDirection = textDirection ?? Directionality.of(context)
34053387
..fit = fit
3406-
..clipBehavior = overflow == Overflow.visible ? Clip.none : clipBehavior;
3388+
..clipBehavior = clipBehavior;
34073389
}
34083390

34093391
@override
@@ -3940,7 +3922,7 @@ class Flex extends MultiChildRenderObjectWidget {
39403922
this.textDirection,
39413923
this.verticalDirection = VerticalDirection.down,
39423924
this.textBaseline = TextBaseline.alphabetic,
3943-
this.clipBehavior = Clip.hardEdge,
3925+
this.clipBehavior = Clip.none,
39443926
List<Widget> children = const <Widget>[],
39453927
}) : assert(direction != null),
39463928
assert(mainAxisAlignment != null),
@@ -4040,10 +4022,9 @@ class Flex extends MultiChildRenderObjectWidget {
40404022
/// Defaults to [TextBaseline.alphabetic].
40414023
final TextBaseline? textBaseline;
40424024

4043-
// TODO(liyuqian): defaults to [Clip.none] once Google references are updated.
40444025
/// {@macro flutter.widgets.Clip}
40454026
///
4046-
/// Defaults to [Clip.hardEdge].
4027+
/// Defaults to [Clip.none].
40474028
final Clip clipBehavior;
40484029

40494030
bool get _needTextDirection {
@@ -4795,7 +4776,7 @@ class Wrap extends MultiChildRenderObjectWidget {
47954776
this.crossAxisAlignment = WrapCrossAlignment.start,
47964777
this.textDirection,
47974778
this.verticalDirection = VerticalDirection.down,
4798-
this.clipBehavior = Clip.hardEdge,
4779+
this.clipBehavior = Clip.none,
47994780
List<Widget> children = const <Widget>[],
48004781
}) : assert(clipBehavior != null), super(key: key, children: children);
48014782

@@ -4931,10 +4912,9 @@ class Wrap extends MultiChildRenderObjectWidget {
49314912
/// [verticalDirection] must not be null.
49324913
final VerticalDirection verticalDirection;
49334914

4934-
// TODO(liyuqian): defaults to [Clip.none] once Google references are updated.
49354915
/// {@macro flutter.widgets.Clip}
49364916
///
4937-
/// Defaults to [Clip.hardEdge].
4917+
/// Defaults to [Clip.none].
49384918
final Clip clipBehavior;
49394919

49404920
@override

packages/flutter/test/widgets/basic_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ void main() {
340340
testWidgets('UnconstrainedBox can set and update clipBehavior', (WidgetTester tester) async {
341341
await tester.pumpWidget(const UnconstrainedBox());
342342
final RenderUnconstrainedBox renderObject = tester.allRenderObjects.whereType<RenderUnconstrainedBox>().first;
343-
expect(renderObject.clipBehavior, equals(Clip.hardEdge));
343+
expect(renderObject.clipBehavior, equals(Clip.none));
344344

345345
await tester.pumpWidget(const UnconstrainedBox(clipBehavior: Clip.antiAlias));
346346
expect(renderObject.clipBehavior, equals(Clip.antiAlias));

packages/flutter/test/widgets/flex_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void main() {
146146
testWidgets('Can set and update clipBehavior', (WidgetTester tester) async {
147147
await tester.pumpWidget(Flex(direction: Axis.vertical));
148148
final RenderFlex renderObject = tester.allRenderObjects.whereType<RenderFlex>().first;
149-
expect(renderObject.clipBehavior, equals(Clip.hardEdge));
149+
expect(renderObject.clipBehavior, equals(Clip.none));
150150

151151
await tester.pumpWidget(Flex(direction: Axis.vertical, clipBehavior: Clip.antiAlias));
152152
expect(renderObject.clipBehavior, equals(Clip.antiAlias));

packages/flutter/test/widgets/stack_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,6 @@ void main() {
453453
textDirection: TextDirection.ltr,
454454
child: Center(
455455
child: Stack(
456-
overflow: Overflow.visible,
457456
clipBehavior: Clip.none,
458457
children: const <Widget>[
459458
SizedBox(

packages/flutter/test/widgets/wrap_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ void main() {
902902
testWidgets('Wrap can set and update clipBehavior', (WidgetTester tester) async {
903903
await tester.pumpWidget(Wrap(textDirection: TextDirection.ltr));
904904
final RenderWrap renderObject = tester.allRenderObjects.whereType<RenderWrap>().first;
905-
expect(renderObject.clipBehavior, equals(Clip.hardEdge));
905+
expect(renderObject.clipBehavior, equals(Clip.none));
906906

907907
await tester.pumpWidget(Wrap(textDirection: TextDirection.ltr, clipBehavior: Clip.antiAlias));
908908
expect(renderObject.clipBehavior, equals(Clip.antiAlias));

0 commit comments

Comments
 (0)