-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy patheasy_example.dart
30 lines (28 loc) · 1.13 KB
/
easy_example.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import 'package:example/easy/easy_example_provider.dart';
import 'package:flutter/material.dart';
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
import 'package:riverpod_infinite_scroll/riverpod_infinite_scroll.dart';
class EasyExample extends StatelessWidget {
const EasyExample({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: RiverPagedBuilder<int, Post>(
// the first page we will ask
firstPageKey: 1,
// The [StateNotifierProvider] that holds the logic and the list of Posts
provider: easyExampleProvider,
// a function that build a single Post
itemBuilder: (context, item, index) => ListTile(
leading: CircleAvatar(child: Image.network(item.image)),
title: Text(item.title),
),
// The type of list we want to render
// This can be any of the [infinite_scroll_pagination] widgets
pagedBuilder: (controller, builder) => PagedListView(
pagingController: controller, builderDelegate: builder),
),
);
}
}