Skip to content

Commit

Permalink
fix: Removes scroll from onError and onEmpty
Browse files Browse the repository at this point in the history
  • Loading branch information
vedartm committed Nov 17, 2021
1 parent 69c1f3d commit 9fb1fc4
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions lib/paginate_firestore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PaginateFirestore extends StatefulWidget {
this.onError,
this.onReachedEnd,
this.onLoaded,
this.emptyDisplay = const EmptyDisplay(),
this.onEmpty = const EmptyDisplay(),
this.separator = const EmptySeparator(),
this.initialLoader = const InitialLoader(),
this.bottomLoader = const BottomLoader(),
Expand All @@ -50,7 +50,7 @@ class PaginateFirestore extends StatefulWidget {
}) : super(key: key);

final Widget bottomLoader;
final Widget emptyDisplay;
final Widget onEmpty;
final SliverGridDelegate gridDelegate;
final Widget initialLoader;
final PaginateBuilderType itemBuilderType;
Expand Down Expand Up @@ -102,15 +102,9 @@ class _PaginateFirestoreState extends State<PaginateFirestore> {
if (state is PaginationInitial) {
return widget.initialLoader;
} else if (state is PaginationError) {
return SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: SizedBox(
child: (widget.onError != null)
? widget.onError!(state.error)
: ErrorDisplay(exception: state.error),
height: MediaQuery.of(context).size.height,
),
);
return (widget.onError != null)
? widget.onError!(state.error)
: ErrorDisplay(exception: state.error);
} else {
final loadedState = state as PaginationLoaded;
if (widget.onLoaded != null) {
Expand All @@ -121,13 +115,7 @@ class _PaginateFirestoreState extends State<PaginateFirestore> {
}

if (loadedState.documentSnapshots.isEmpty) {
return SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: SizedBox(
child: widget.emptyDisplay,
height: MediaQuery.of(context).size.height,
),
);
return widget.onEmpty;
}
return widget.itemBuilderType == PaginateBuilderType.listView
? _buildListView(loadedState)
Expand Down

0 comments on commit 9fb1fc4

Please sign in to comment.