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 {
// dragged widget, hence the use of Overflow.visible.
return Center(
child: Stack(
overflow: Overflow.visible,
clipBehavior: Clip.none,
children: <Widget>[
Positioned(
top: _kActivityIndicatorMargin,
......
......@@ -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
......
......@@ -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<Widget> children = const <Widget>[],
}) : 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<Widget> children = const <Widget>[],
}) : 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<Widget> children = const <Widget>[],
}) : 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
......
......@@ -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));
......
......@@ -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));
......
......@@ -453,7 +453,6 @@ void main() {
textDirection: TextDirection.ltr,
child: Center(
child: Stack(
overflow: Overflow.visible,
clipBehavior: Clip.none,
children: const <Widget>[
SizedBox(
......
......@@ -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));
......
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