Skip to content

Commit

Permalink
feat: add padding api to InfiniteList (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel authored Feb 19, 2021
1 parent b8e0d57 commit 6a27fc3
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
## [0.2.1] - 02/19/21

- feat: add `padding` api to `InfiniteList`

## [0.2.0] - 02/17/21

- feat: add reverse
- feat: support custom scroll controller
- feat: add `reverse` api to `InfiniteList`
- feat: add `ScrollController` to `InfiniteList`

## [0.1.1] - 02/11/21

Expand Down
1 change: 1 addition & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class _CustomInfiniteList extends StatelessWidget {
return Scaffold(
appBar: AppBar(title: const Text('Custom Infinite List')),
body: InfiniteList<String>(
padding: const EdgeInsets.all(0),
itemLoader: _itemLoader,
builder: InfiniteListBuilder<String>(
empty: (context) => _Empty(),
Expand Down
5 changes: 5 additions & 0 deletions lib/very_good_infinite_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class InfiniteList<T> extends StatefulWidget {
this.debounceDuration,
this.reverse = false,
this.onError,
this.padding,
ScrollController scrollController,
double scrollOffsetThreshold,
}) : assert(itemLoader != null),
Expand All @@ -128,6 +129,9 @@ class InfiniteList<T> extends StatefulWidget {
scrollOffsetThreshold ?? _kScrollOffsetThreshold,
super(key: key);

/// The amount of space by which to inset the children of the [builder].
final EdgeInsetsGeometry padding;

/// {@macro infinite_list_builder}
final InfiniteListBuilder<T> builder;

Expand Down Expand Up @@ -274,6 +278,7 @@ class _InfiniteListState<T> extends State<InfiniteList<T>> {
}

return ListView.builder(
padding: widget.padding,
reverse: widget.reverse,
controller: _scrollController,
itemCount: itemCount,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: very_good_infinite_list
description: >-
A Very Good Infinite List Widget created by Very Good Ventures.
Comes in handy when making activity feeds, news feeds, etc.
version: 0.2.0
version: 0.2.1
repository: https://github.com/VeryGoodOpenSource/very_good_infinite_list
issue_tracker: https://github.com/VeryGoodOpenSource/very_good_infinite_list/issues
homepage: https://github.com/VeryGoodOpenSource/very_good_infinite_list
Expand Down
19 changes: 19 additions & 0 deletions test/very_good_infinite_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,25 @@ void main() {
expect(listView.reverse, isFalse);
});

testWidgets('list view supports custom padding', (tester) async {
final itemLoader = (int limit, {int start}) async {
return List.generate(15, (i) => i);
};
const padding = EdgeInsets.all(16);
await tester.pumpApp(
InfiniteList(
padding: padding,
itemLoader: itemLoader,
builder: InfiniteListBuilder(success: (_, __) => const SizedBox()),
),
);

await tester.pump();

final listView = tester.widget<ListView>(find.byType(ListView));
expect(listView.padding, equals(padding));
});

testWidgets('invokes itemLoader immediately', (tester) async {
var itemLoaderCallCount = 0;
final itemLoader = (int limit, {int start}) {
Expand Down

0 comments on commit 6a27fc3

Please sign in to comment.