Skip to content

added clipBehavior to scrollable_positioned_list #482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class PositionedList extends StatefulWidget {
this.addSemanticIndexes = true,
this.addRepaintBoundaries = true,
this.addAutomaticKeepAlives = true,
this.clipBehavior = Clip.hardEdge,
}) : assert(itemCount != null),
assert(itemBuilder != null),
assert((positionedIndex == 0) || (positionedIndex < itemCount)),
Expand Down Expand Up @@ -132,6 +133,11 @@ class PositionedList extends StatefulWidget {
/// See [SliverChildBuilderDelegate.addAutomaticKeepAlives].
final bool addAutomaticKeepAlives;

/// {@macro flutter.material.Material.clipBehavior}
///
/// Defaults to [Clip.hardEdge].
final Clip clipBehavior;

@override
State<StatefulWidget> createState() => _PositionedListState();
}
Expand Down Expand Up @@ -177,6 +183,7 @@ class _PositionedListState extends State<PositionedList> {
physics: widget.physics,
shrinkWrap: widget.shrinkWrap,
semanticChildCount: widget.semanticChildCount ?? widget.itemCount,
clipBehavior: widget.clipBehavior,
slivers: <Widget>[
if (widget.positionedIndex > 0)
SliverPadding(
Expand Down
7 changes: 6 additions & 1 deletion packages/scrollable_positioned_list/lib/src/scroll_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'viewport.dart';
/// to be within 0 and 1. See [CustomScrollView] for more information.
class UnboundedCustomScrollView extends CustomScrollView {
final bool _shrinkWrap;

final Clip _clipBehavior;
const UnboundedCustomScrollView({
Key? key,
Axis scrollDirection = Axis.vertical,
Expand All @@ -28,8 +28,10 @@ class UnboundedCustomScrollView extends CustomScrollView {
List<Widget> slivers = const <Widget>[],
int? semanticChildCount,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
Clip clipBehavior = Clip.hardEdge,
}) : _shrinkWrap = shrinkWrap,
_anchor = anchor,
_clipBehavior = clipBehavior,
super(
key: key,
scrollDirection: scrollDirection,
Expand All @@ -42,6 +44,7 @@ class UnboundedCustomScrollView extends CustomScrollView {
cacheExtent: cacheExtent,
semanticChildCount: semanticChildCount,
dragStartBehavior: dragStartBehavior,
clipBehavior: clipBehavior,
slivers: slivers,
);

Expand Down Expand Up @@ -69,6 +72,7 @@ class UnboundedCustomScrollView extends CustomScrollView {
cacheExtent: cacheExtent,
center: center,
anchor: anchor,
clipBehavior: _clipBehavior,
);
}
return UnboundedViewport(
Expand All @@ -78,6 +82,7 @@ class UnboundedCustomScrollView extends CustomScrollView {
cacheExtent: cacheExtent,
center: center,
anchor: anchor,
clipBehavior: _clipBehavior,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class ScrollablePositionedList extends StatefulWidget {
this.addAutomaticKeepAlives = true,
this.addRepaintBoundaries = true,
this.minCacheExtent,
this.clipBehavior = Clip.hardEdge,
}) : assert(itemCount != null),
assert(itemBuilder != null),
itemPositionsNotifier = itemPositionsListener as ItemPositionsNotifier?,
Expand Down Expand Up @@ -87,6 +88,7 @@ class ScrollablePositionedList extends StatefulWidget {
this.addAutomaticKeepAlives = true,
this.addRepaintBoundaries = true,
this.minCacheExtent,
this.clipBehavior = Clip.hardEdge,
}) : assert(itemCount != null),
assert(itemBuilder != null),
assert(separatorBuilder != null),
Expand Down Expand Up @@ -186,6 +188,11 @@ class ScrollablePositionedList extends StatefulWidget {
/// cache extent.
final double? minCacheExtent;

/// {@macro flutter.material.Material.clipBehavior}
///
/// Defaults to [Clip.hardEdge].
final Clip clipBehavior;

@override
State<StatefulWidget> createState() => _ScrollablePositionedListState();
}
Expand Down Expand Up @@ -435,6 +442,7 @@ class _ScrollablePositionedListState extends State<ScrollablePositionedList>
addSemanticIndexes: widget.addSemanticIndexes,
semanticChildCount: widget.semanticChildCount,
padding: widget.padding,
clipBehavior: widget.clipBehavior,
addAutomaticKeepAlives: widget.addAutomaticKeepAlives,
addRepaintBoundaries: widget.addRepaintBoundaries,
),
Expand All @@ -450,6 +458,7 @@ class _ScrollablePositionedListState extends State<ScrollablePositionedList>
child: NotificationListener<ScrollNotification>(
onNotification: (_) => false,
child: PositionedList(
clipBehavior: widget.clipBehavior,
itemBuilder: widget.itemBuilder,
separatorBuilder: widget.separatorBuilder,
itemCount: widget.itemCount,
Expand Down
4 changes: 4 additions & 0 deletions packages/scrollable_positioned_list/lib/src/viewport.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class UnboundedViewport extends Viewport {
required ViewportOffset offset,
Key? center,
double? cacheExtent,
Clip clipBehavior = Clip.hardEdge,
List<Widget> slivers = const <Widget>[],
}) : _anchor = anchor,
super(
Expand All @@ -30,6 +31,7 @@ class UnboundedViewport extends Viewport {
offset: offset,
center: center,
cacheExtent: cacheExtent,
clipBehavior: clipBehavior,
slivers: slivers);

// [Viewport] enforces constraints on [Viewport.anchor], so we need our own
Expand Down Expand Up @@ -70,13 +72,15 @@ class UnboundedRenderViewport extends RenderViewport {
List<RenderSliver>? children,
RenderSliver? center,
double? cacheExtent,
Clip clipBehavior = Clip.hardEdge,
}) : _anchor = anchor,
super(
axisDirection: axisDirection,
crossAxisDirection: crossAxisDirection,
offset: offset,
center: center,
cacheExtent: cacheExtent,
clipBehavior: clipBehavior,
children: children);

static const int _maxLayoutCycles = 10;
Expand Down
2 changes: 2 additions & 0 deletions packages/scrollable_positioned_list/lib/src/wrapping.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class CustomShrinkWrappingViewport extends CustomViewport {
List<RenderSliver>? children,
Key? center,
double? cacheExtent,
Clip clipBehavior = Clip.hardEdge,
List<Widget> slivers = const <Widget>[],
}) : _anchor = anchor,
super(
Expand All @@ -54,6 +55,7 @@ class CustomShrinkWrappingViewport extends CustomViewport {
offset: offset,
center: center,
cacheExtent: cacheExtent,
clipBehavior: clipBehavior,
slivers: slivers);

// [Viewport] enforces constraints on [Viewport.anchor], so we need our own
Expand Down