jajpa/paging_library
用於分頁列表視圖的 Flutter 套件
- Stars
- 35
- Forks
- 7
- 最近推送(UTC)
- 2021年11月19日
- 專案狀態
- 未封存
語言DartJava
技術主題
使用的依賴
依賴清單 2 項
- flutter
{"sdk":"flutter"} - flutter_test開發依賴
{"sdk":"flutter"}
原始 README
以下為英文專案原文快照,最新內容請造訪 GitHub。
展開 / 收合專案 README
paging
A Flutter package for paginating a list view
Installation
Add this to your package's pubspec.yaml file
dependencies:
...
paging: ^latest.version.here
Usage
First import paging.dart
import 'package:paging/paging.dart';
Simple to use. You can pass a type <T> as a parameter to the widget, by default dynamic is assumed.
There are two required parameters:
- pageBuilder: requires a Future of List<T> and gives you the current size of list
- itemBuilder: requires a widget and gives you the item of type <T> to be displayed
// mocking a network call
Future<List<String>> pageData(int previousCount) async {
await Future.delayed(Duration(seconds: 0, milliseconds: 2000));
List<String> dummyList = List();
if (previousCount < 30) {
// stop loading after 30 items
for (int i = previousCount; i < previousCount + _COUNT; i++) {
dummyList.add('Item $i');
}
}
return dummyList;
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Pagination List')),
body: Pagination<String>(
pageBuilder: (currentSize) => pageData(currentSize),
itemBuilder: (index, item){
return Container(
color: Colors.yellow,
height: 48,
child: Text(item),
);
},
),
);
}
Screenshots
https://i.imgur.com/JM1HBvE.gifGetting Started
This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.
For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.