Skip to content

Commit

Permalink
refactor: move separatorBuilder in a .separated constructor.
Browse files Browse the repository at this point in the history
Signed-off-by: Sahil Kumar <xdsahil@gmail.com>
  • Loading branch information
xsahil03x committed Jan 30, 2024
1 parent c146df4 commit 6a7de78
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 4 deletions.
31 changes: 30 additions & 1 deletion lib/src/widget/bidirectional_paging_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,36 @@ class BidirectionalPagingListView<Key, Value> extends StatefulWidget {
super.key,
required this.pager,
required this.itemBuilder,
this.separatorBuilder,
required this.emptyBuilder,
required this.errorBuilder,
required this.loadingBuilder,
this.appendStateBuilder = defaultAppendStateBuilder,
this.prependStateBuilder = defaultPrependStateBuilder,
this.headerBuilder,
this.footerBuilder,
this.scrollDirection = Axis.vertical,
this.reverse = false,
this.controller,
this.primary,
this.physics,
this.scrollBehavior,
this.padding,
this.findChildIndexCallback,
this.addAutomaticKeepAlives = true,
this.addRepaintBoundaries = true,
this.addSemanticIndexes = true,
this.cacheExtent,
this.dragStartBehavior = DragStartBehavior.start,
this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
this.restorationId,
this.clipBehavior = Clip.hardEdge,
}) : separatorBuilder = null;

const BidirectionalPagingListView.separated({
super.key,
required this.pager,
required this.itemBuilder,
required this.separatorBuilder,
required this.emptyBuilder,
required this.errorBuilder,
required this.loadingBuilder,
Expand Down
49 changes: 47 additions & 2 deletions lib/src/widget/paging_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,36 @@ class PagingListView<Key, Value> extends BoxScrollView {
super.key,
required this.pager,
required this.itemBuilder,
this.separatorBuilder,
required this.emptyBuilder,
required this.errorBuilder,
required this.loadingBuilder,
this.appendStateBuilder = defaultAppendStateBuilder,
this.prependStateBuilder = defaultPrependStateBuilder,
super.scrollDirection,
super.reverse,
super.controller,
super.primary,
super.physics,
super.shrinkWrap,
super.padding,
this.findChildIndexCallback,
this.addAutomaticKeepAlives = true,
this.addRepaintBoundaries = true,
this.addSemanticIndexes = true,
super.cacheExtent,
int? semanticChildCount,
super.dragStartBehavior,
super.keyboardDismissBehavior,
super.restorationId,
super.clipBehavior,
}) : separatorBuilder = null,
super(semanticChildCount: semanticChildCount);

const PagingListView.separated({
super.key,
required this.pager,
required this.itemBuilder,
required this.separatorBuilder,
required this.emptyBuilder,
required this.errorBuilder,
required this.loadingBuilder,
Expand Down Expand Up @@ -74,10 +103,26 @@ class PagingListView<Key, Value> extends BoxScrollView {

@override
Widget buildChildLayout(BuildContext context) {
if (separatorBuilder != null) {
return PagingSliverList.separated(
pager: pager,
itemBuilder: itemBuilder,
separatorBuilder: separatorBuilder,
emptyBuilder: emptyBuilder,
errorBuilder: errorBuilder,
loadingBuilder: loadingBuilder,
appendStateBuilder: appendStateBuilder,
prependStateBuilder: prependStateBuilder,
findChildIndexCallback: findChildIndexCallback,
addAutomaticKeepAlives: addAutomaticKeepAlives,
addRepaintBoundaries: addRepaintBoundaries,
addSemanticIndexes: addSemanticIndexes,
);
}

return PagingSliverList(
pager: pager,
itemBuilder: itemBuilder,
separatorBuilder: separatorBuilder,
emptyBuilder: emptyBuilder,
errorBuilder: errorBuilder,
loadingBuilder: loadingBuilder,
Expand Down
19 changes: 18 additions & 1 deletion lib/src/widget/paging_sliver_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,24 @@ class PagingSliverList<Key, Value> extends StatefulWidget {
super.key,
required this.pager,
required this.itemBuilder,
this.separatorBuilder,
required this.emptyBuilder,
required this.errorBuilder,
required this.loadingBuilder,
this.appendStateBuilder = defaultAppendStateBuilder,
this.prependStateBuilder = defaultPrependStateBuilder,
this.headerBuilder,
this.footerBuilder,
this.findChildIndexCallback,
this.addAutomaticKeepAlives = true,
this.addRepaintBoundaries = true,
this.addSemanticIndexes = true,
}) : separatorBuilder = null;

const PagingSliverList.separated({
super.key,
required this.pager,
required this.itemBuilder,
required this.separatorBuilder,
required this.emptyBuilder,
required this.errorBuilder,
required this.loadingBuilder,
Expand Down

0 comments on commit 6a7de78

Please sign in to comment.