@@ -143,8 +143,8 @@ class RenderListWheelViewport
143
143
double overAndUnderCenterOpacity = 1 ,
144
144
@required double itemExtent,
145
145
double squeeze = 1 ,
146
- bool clipToSize = true ,
147
146
bool renderChildrenOutsideViewport = false ,
147
+ Clip clipBehavior = Clip .none,
148
148
List <RenderBox > children,
149
149
}) : assert (childManager != null ),
150
150
assert (offset != null ),
@@ -163,11 +163,11 @@ class RenderListWheelViewport
163
163
assert (squeeze != null ),
164
164
assert (squeeze > 0 ),
165
165
assert (itemExtent > 0 ),
166
- assert (clipToSize != null ),
167
166
assert (renderChildrenOutsideViewport != null ),
167
+ assert (clipBehavior != null ),
168
168
assert (
169
- ! renderChildrenOutsideViewport || ! clipToSize ,
170
- clipToSizeAndRenderChildrenOutsideViewportConflict ,
169
+ ! renderChildrenOutsideViewport || clipBehavior == Clip .none ,
170
+ clipBehaviorAndRenderChildrenOutsideViewportConflict ,
171
171
),
172
172
_offset = offset,
173
173
_diameterRatio = diameterRatio,
@@ -178,8 +178,8 @@ class RenderListWheelViewport
178
178
_overAndUnderCenterOpacity = overAndUnderCenterOpacity,
179
179
_itemExtent = itemExtent,
180
180
_squeeze = squeeze,
181
- _clipToSize = clipToSize ,
182
- _renderChildrenOutsideViewport = renderChildrenOutsideViewport {
181
+ _renderChildrenOutsideViewport = renderChildrenOutsideViewport ,
182
+ _clipBehavior = clipBehavior {
183
183
addAll (children);
184
184
}
185
185
@@ -199,10 +199,10 @@ class RenderListWheelViewport
199
199
'be clipped in the z-axis and therefore not renderable. Value must be '
200
200
'between 0 and 0.01.' ;
201
201
202
- /// An error message to show when [clipToSize ] and [renderChildrenOutsideViewport]
202
+ /// An error message to show when [clipBehavior ] and [renderChildrenOutsideViewport]
203
203
/// are set to conflicting values.
204
- static const String clipToSizeAndRenderChildrenOutsideViewportConflict =
205
- 'Cannot renderChildrenOutsideViewport and clipToSize since children '
204
+ static const String clipBehaviorAndRenderChildrenOutsideViewportConflict =
205
+ 'Cannot renderChildrenOutsideViewport and clip since children '
206
206
'rendered outside will be clipped anyway.' ;
207
207
208
208
/// The delegate that manages the children of this object.
@@ -441,46 +441,23 @@ class RenderListWheelViewport
441
441
markNeedsSemanticsUpdate ();
442
442
}
443
443
444
- /// {@template flutter.rendering.wheelList.clipToSize}
445
- /// Whether to clip painted children to the inside of this viewport.
446
- ///
447
- /// Defaults to [true] . Must not be null.
448
- ///
449
- /// If this is false and [renderChildrenOutsideViewport] is false, the
450
- /// first and last children may be painted partly outside of this scroll view.
451
- /// {@endtemplate}
452
- bool get clipToSize => _clipToSize;
453
- bool _clipToSize;
454
- set clipToSize (bool value) {
455
- assert (value != null );
456
- assert (
457
- ! renderChildrenOutsideViewport || ! clipToSize,
458
- clipToSizeAndRenderChildrenOutsideViewportConflict,
459
- );
460
- if (value == _clipToSize)
461
- return ;
462
- _clipToSize = value;
463
- markNeedsPaint ();
464
- markNeedsSemanticsUpdate ();
465
- }
466
-
467
444
/// {@template flutter.rendering.wheelList.renderChildrenOutsideViewport}
468
445
/// Whether to paint children inside the viewport only.
469
446
///
470
447
/// If false, every child will be painted. However the [Scrollable] is still
471
448
/// the size of the viewport and detects gestures inside only.
472
449
///
473
- /// Defaults to [false] . Must not be null. Cannot be true if [clipToSize ]
474
- /// is also true since children outside the viewport will be clipped, and
450
+ /// Defaults to [false] . Must not be null. Cannot be true if [clipBehavior ]
451
+ /// is not [Clip.none] since children outside the viewport will be clipped, and
475
452
/// therefore cannot render children outside the viewport.
476
453
/// {@endtemplate}
477
454
bool get renderChildrenOutsideViewport => _renderChildrenOutsideViewport;
478
455
bool _renderChildrenOutsideViewport;
479
456
set renderChildrenOutsideViewport (bool value) {
480
457
assert (value != null );
481
458
assert (
482
- ! renderChildrenOutsideViewport || ! clipToSize ,
483
- clipToSizeAndRenderChildrenOutsideViewportConflict ,
459
+ ! renderChildrenOutsideViewport || clipBehavior == Clip .none ,
460
+ clipBehaviorAndRenderChildrenOutsideViewportConflict ,
484
461
);
485
462
if (value == _renderChildrenOutsideViewport)
486
463
return ;
@@ -489,6 +466,20 @@ class RenderListWheelViewport
489
466
markNeedsSemanticsUpdate ();
490
467
}
491
468
469
+ /// {@macro flutter.widgets.Clip}
470
+ ///
471
+ /// Defaults to [Clip.hardEdge] , and must not be null.
472
+ Clip get clipBehavior => _clipBehavior;
473
+ Clip _clipBehavior = Clip .hardEdge;
474
+ set clipBehavior (Clip value) {
475
+ assert (value != null );
476
+ if (value != _clipBehavior) {
477
+ _clipBehavior = value;
478
+ markNeedsPaint ();
479
+ markNeedsSemanticsUpdate ();
480
+ }
481
+ }
482
+
492
483
void _hasScrolled () {
493
484
markNeedsLayout ();
494
485
markNeedsSemanticsUpdate ();
@@ -787,12 +778,13 @@ class RenderListWheelViewport
787
778
@override
788
779
void paint (PaintingContext context, Offset offset) {
789
780
if (childCount > 0 ) {
790
- if (_clipToSize && _shouldClipAtCurrentOffset () ) {
781
+ if (_shouldClipAtCurrentOffset () && clipBehavior != Clip .none ) {
791
782
context.pushClipRect (
792
783
needsCompositing,
793
784
offset,
794
785
Offset .zero & size,
795
786
_paintVisibleChildren,
787
+ clipBehavior: clipBehavior,
796
788
);
797
789
} else {
798
790
_paintVisibleChildren (context, offset);
0 commit comments