lazy_refreshing_listview 0.0.3
lazy_refreshing_listview: ^0.0.3 copied to clipboard
A flutter package to handle listview with refresh, and lazy scrolling smartly
lazy_refreshing_listview #
A smart and reusable Flutter widget that enables pull-to-refresh and infinite scroll (lazy loading) for any ListView
with minimal setup.
Features #
- π Pull-to-refresh functionality
- β¬οΈ Infinite scrolling (lazy loading)
- π Works with any
ListView
widget - π± Custom scroll controller support
- βοΈ Easy-to-use callbacks
- π¨ Customizable refresh header and loading footer
Usage #
import 'package:lazy_refreshing_listview/lazy_refreshing_listview.dart';
LazyRefreshingListView(
onRefresh: () async {
// Handle refresh logic
await _refreshData();
},
onLazyLoad: () async {
// Handle load more logic
await _loadMoreData();
},
listView: ListView.builder(
itemCount: items.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(items[index].title),
subtitle: Text(items[index].description),
);
},
),
)
API Reference #
LazyRefreshingListView #
Property | Type | Default | Description |
---|---|---|---|
listView |
ListView |
required | The ListView widget to wrap |
onRefresh |
Future<void> Function()? |
null |
Callback when user pulls to refresh |
onLazyLoad |
Future<void> Function()? |
null |
Callback when scrolled to bottom |
scrollController |
ScrollController? |
null |
Optional scroll controller |
disableRefresh |
bool |
false |
Disable pull-to-refresh functionality |
disableLazyLoading |
bool |
false |
Disable infinite scroll functionality |
header |
Widget? |
null |
Custom refresh indicator widget |
footer |
Widget? |
null |
Custom loading indicator widget |
Advanced Usage #
Custom Refresh Header #
LazyRefreshingListView(
header: Container(
height: 60,
child: Center(
child: Text(
'Pull to refresh',
style: TextStyle(color: Colors.blue),
),
),
),
onRefresh: _onRefresh,
onLazyLoad: _onLazyLoad,
listView: yourListView,
)
Custom Loading Footer #
LazyRefreshingListView(
footer: Container(
padding: EdgeInsets.all(16),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircularProgressIndicator(),
SizedBox(width: 16),
Text('Loading more...'),
],
),
),
onRefresh: _onRefresh,
onLazyLoad: _onLazyLoad,
listView: yourListView,
)
Disable Specific Features #
// Only enable pull-to-refresh
LazyRefreshingListView(
disableLazyLoading: true,
onRefresh: _onRefresh,
listView: yourListView,
)
// Only enable lazy loading
LazyRefreshingListView(
disableRefresh: true,
onLazyLoad: _onLazyLoad,
listView: yourListView,
)
Tips #
- The widget automatically handles scroll detection for lazy loading
- Pull-to-refresh works with both iOS and Android native feel
- Compatible with
ListView.builder
,ListView.separated
, and custom ListViews - Use
disableRefresh
ordisableLazyLoading
to control specific features - The
onLazyLoad
callback is triggered when the user scrolls to within 200 pixels of the bottom
Contributing #
Contributions are welcome! Please read our contributing guidelines and submit pull requests to our GitHub repository.
Issues and Feedback #
Please file issues and feature requests on our GitHub Issues page.