Skip to content

Commit 67c8f0b

Browse files
committed
feat: load more on feed list
1 parent df98e27 commit 67c8f0b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

sample_app/lib/screens/home/widgets/user_feed_view.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class _UserFeedViewState extends State<UserFeedView> {
5151
stateNotifier: feed.state,
5252
builder: (context, state, child) {
5353
final activities = state.activities;
54+
final canLoadMore = state.canLoadMoreActivities;
55+
5456
if (activities.isEmpty) return const EmptyActivities();
5557

5658
return RefreshIndicator(
@@ -63,12 +65,21 @@ class _UserFeedViewState extends State<UserFeedView> {
6365
},
6466
),
6567
child: ListView.separated(
66-
itemCount: activities.length,
68+
itemCount: activities.length + 1,
6769
separatorBuilder: (context, index) => Divider(
6870
height: 1,
6971
color: context.appColors.borders,
7072
),
7173
itemBuilder: (context, index) {
74+
if (index == activities.length) {
75+
return canLoadMore
76+
? TextButton(
77+
onPressed: () => feed.queryMoreActivities(),
78+
child: const Text('Load more...'),
79+
)
80+
: const Text('End of feed');
81+
}
82+
7283
final activity = activities[index];
7384
final parentActivity = activity.parent;
7485
final baseActivity = activity.parent ?? activity;

0 commit comments

Comments
 (0)