Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ InfiniteList<String>(
// Is set to `false` by default.
reverse: false,

// Indicates if the extent of the ScrollView in the scrollDirection
// should be determined by the contents being viewed.
//
// Is set to `false` by default.
shrinkWrap: false,

// The duration with which calls to [onFetchData] will be debounced.
//
// Is set to a duration of 100 milliseconds by default.
Expand Down
10 changes: 10 additions & 0 deletions lib/src/infinite_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class InfiniteList extends StatelessWidget {
this.cacheExtent,
this.debounceDuration = defaultDebounceDuration,
this.reverse = false,
this.shrinkWrap = false,
this.isLoading = false,
this.hasError = false,
this.hasReachedMax = false,
Expand Down Expand Up @@ -77,6 +78,14 @@ class InfiniteList extends StatelessWidget {
/// {@endtemplate}
final bool reverse;

/// Indicates if the extent of the [ScrollView] in the [scrollDirection]
/// should be determined by the contents being viewed.
///
/// See also:
///
/// * [CustomScrollView.shrinkWrap], for more details about this flag.
final bool shrinkWrap;

/// {@template item_count}
/// The amount of items that need to be rendered by the [itemBuilder].
///
Expand Down Expand Up @@ -207,6 +216,7 @@ class InfiniteList extends StatelessWidget {
return CustomScrollView(
scrollDirection: scrollDirection,
reverse: reverse,
shrinkWrap: shrinkWrap,
controller: scrollController,
physics: physics,
cacheExtent: cacheExtent,
Expand Down
30 changes: 30 additions & 0 deletions test/infinite_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,36 @@ void main() {
tester.widget<CustomScrollView>(find.byType(CustomScrollView));
expect(customScrollView.reverse, reverse);
});

testWidgets('shrinkWrap', (tester) async {
const shrinkWrap = true;
await tester.pumpApp(
InfiniteList(
itemCount: 10,
onFetchData: emptyCallback,
itemBuilder: (_, i) => Text('$i'),
shrinkWrap: shrinkWrap,
),
);

final customScrollView =
tester.widget<CustomScrollView>(find.byType(CustomScrollView));
expect(customScrollView.shrinkWrap, shrinkWrap);
});

testWidgets('shrinkWrap defaults to false', (tester) async {
await tester.pumpApp(
InfiniteList(
itemCount: 10,
onFetchData: emptyCallback,
itemBuilder: (_, i) => Text('$i'),
),
);

final customScrollView =
tester.widget<CustomScrollView>(find.byType(CustomScrollView));
expect(customScrollView.shrinkWrap, false);
});
});

group('centralized properties', () {
Expand Down