Skip to content

Commit

Permalink
Add listview params to PaginatedView
Browse files Browse the repository at this point in the history
  • Loading branch information
getBoolean committed Apr 13, 2024
1 parent fe9ae0e commit b421600
Showing 1 changed file with 56 additions and 5 deletions.
61 changes: 56 additions & 5 deletions packages/pub/pagination/lib/src/paginated_view.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:pagination_dart/pagination_dart.dart';
import 'package:super_sliver_list/super_sliver_list.dart';

final _pageBucket = PageStorageBucket();

// TODO: Add a "scroll to top" button when scrolled
class PaginatedView<T> extends ConsumerWidget {
const PaginatedView({
required this.itemsProviderBuilder,
Expand All @@ -16,11 +16,29 @@ class PaginatedView<T> extends ConsumerWidget {
required this.refreshItemPageProvider,
this.errorItemBuilder,
this.pageSize = 20,
this.shrinkWrap = false,
this.transitionDuration = const Duration(milliseconds: 650),
this.transitionCurve = Curves.easeInOut,
this.reverseTransitionCurve,
this.restorationId,
this.controller,
this.scrollDirection = Axis.vertical,
this.reverse = false,
this.shrinkWrap = false,
this.primary,
this.physics,
this.padding,
ChildIndexGetter? findChildIndexCallback,
bool addAutomaticKeepAlives = true,
bool addRepaintBoundaries = true,
bool addSemanticIndexes = true,
this.cacheExtent,
this.dragStartBehavior = DragStartBehavior.start,
this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.onDrag,
this.clipBehavior = Clip.hardEdge,
this.listController,
this.extentEstimation,
this.extentPrecalculationPolicy,
this.delayPopulatingCacheArea = false,
super.key,
});

Expand All @@ -44,11 +62,31 @@ class PaginatedView<T> extends ConsumerWidget {
Object error,
StackTrace stack,
)? errorItemBuilder;
final bool shrinkWrap;
final Duration transitionDuration;
final Curve transitionCurve;
final Curve? reverseTransitionCurve;

// ScrollView
final Axis scrollDirection;
final bool reverse;
final ScrollController? controller;
final bool? primary;
final ScrollPhysics? physics;
final bool shrinkWrap;
final double? cacheExtent;
final DragStartBehavior dragStartBehavior;
final ScrollViewKeyboardDismissBehavior keyboardDismissBehavior;
final String? restorationId;
final Clip clipBehavior;

// BoxScrollView
final EdgeInsetsGeometry? padding;

// ListView
final ListController? listController;
final ExtentEstimationProvider? extentEstimation;
final ExtentPrecalculationPolicy? extentPrecalculationPolicy;
final bool delayPopulatingCacheArea;

@override
Widget build(BuildContext context, WidgetRef ref) {
Expand All @@ -67,10 +105,23 @@ class PaginatedView<T> extends ConsumerWidget {
},
child: SuperListView.builder(
key: PageStorageKey(restorationId),
scrollDirection: scrollDirection,
reverse: reverse,
controller: controller,
primary: primary,
physics: physics,
shrinkWrap: shrinkWrap,
itemCount: totalResults,
cacheExtent: cacheExtent,
dragStartBehavior: dragStartBehavior,
keyboardDismissBehavior: keyboardDismissBehavior,
restorationId: restorationId,
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
clipBehavior: clipBehavior,
padding: padding,
listController: listController,
extentEstimation: extentEstimation,
extentPrecalculationPolicy: extentPrecalculationPolicy,
delayPopulatingCacheArea: delayPopulatingCacheArea,
itemCount: totalResults,
itemBuilder: (context, index) {
final page = index ~/ pageSize + 1;
final indexInPage = index % pageSize;
Expand Down

0 comments on commit b421600

Please sign in to comment.