Skip to content

Commit

Permalink
Continue the clipBehavior breaking change (#61366)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
liyuqian committed Sep 15, 2020
1 parent f52380b commit 7948a78
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 47 deletions.
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/cupertino/refresh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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: <Widget>[
Positioned(
top: _kActivityIndicatorMargin,
Expand Down
14 changes: 0 additions & 14 deletions packages/flutter/lib/src/rendering/stack.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 8 additions & 28 deletions packages/flutter/lib/src/widgets/basic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export 'package:flutter/rendering.dart' show
LayerLink,
MainAxisAlignment,
MainAxisSize,
Overflow,
MultiChildLayoutDelegate,
PaintingContext,
PointerCancelEvent,
Expand Down Expand Up @@ -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].
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<Widget> children = const <Widget>[],
}) : assert(clipBehavior != null),
Expand Down Expand Up @@ -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].
Expand All @@ -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,
);
}

Expand All @@ -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
Expand Down Expand Up @@ -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<Widget> children = const <Widget>[],
}) : assert(direction != null),
assert(mainAxisAlignment != null),
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<Widget> children = const <Widget>[],
}) : assert(clipBehavior != null), super(key: key, children: children);

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/test/widgets/basic_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<RenderUnconstrainedBox>().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));
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/test/widgets/flex_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<RenderFlex>().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));
Expand Down
1 change: 0 additions & 1 deletion packages/flutter/test/widgets/stack_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,6 @@ void main() {
textDirection: TextDirection.ltr,
child: Center(
child: Stack(
overflow: Overflow.visible,
clipBehavior: Clip.none,
children: const <Widget>[
SizedBox(
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/test/widgets/wrap_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<RenderWrap>().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));
Expand Down

0 comments on commit 7948a78

Please sign in to comment.