flutter_long_list 0.0.2 flutter_long_list: ^0.0.2 copied to clipboard
A Flutter LongList with Provider which supports ListView, GridView and Slivers.
flutter_long_list #
A Flutter LongList with Provider which supports ListView, GridView and Slivers
Features #
- Use Provider4.x to manage list data , and use Selector can improve performance
- Supports ListView, GridView and Slivers
- Custom and easy api
Get started #
Add it to your pubspec.yaml file:
dependencies:
flutter_long_list: ^0.0.1
Install packages from the command line
flutter packages get
If you like this package, consider supporting it by giving it a star on Github and a like on pub.dev ❤️
Usage #
How to create a GridView By flutter_long_list:
- use ChangeNotifierProvider
ChangeNotifierProvider<LongListProvider<T>>(
create: (_) => LongListProvider<T>(),
child: GridViewDemo(),
);
- init GridView
·param id: list custom id if you use globalStore is required.
·param pageSize: list load more need pagesize to request.
·param request: list load more function, offset = page * pageSize(page initialValue = 0).
@override
initState() {
longListProvider.init(
id: id,
pageSize: 5,
request: (int offset) async => await _getList(offset),
);
// your code...
}
- render GridView
·param id: list custom id you have inited.
·param gridDelegate: gridView property.
·param mode: enum LongListMode {list, grid, sliver_list, sliver_grid}
·param itemWidget: (BuildContext context, LongListProvider
LongList<T>(
id: id,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 10.0,
mainAxisSpacing: 10.0,
),
padding: EdgeInsets.only(left: 10, right: 10),
mode: LongListMode.grid,
itemWidget: itemWidget,
)
Then you have finished to create a LongList GridView Widget easily!