retro_infinity_scroll 0.0.3 retro_infinity_scroll: ^0.0.3 copied to clipboard
A Flutter plugin to implement infinity scroll and inflact paginated data into a ListView.
retro_infinity_scroll #
A Flutter plugin to implement infinity scroll and inflact paginated data into a ListView
Features #
- Load more items when user reached the last
- Swipe to refresh (default and customization available)
- Custom Widget if list is empty or having errors
- Custom Widget while loading the data
Getting Started #
- Add
retro_infinity_scroll
as dependancy inpubspec.yaml
dependencies:
retro_infinity_scroll: <latest version>
- Import plugin class to your file
import 'package:retro_infinity_scroll/retro_infinity_scroll.dart';
Simple use | |
RetroListView( hasMore: false, itemCount: _photos.length, stateType: _loading ? InfiniteScrollStateType.loading : _error ? InfiniteScrollStateType.error : InfiniteScrollStateType.loaded, itemBuilder: (context, index)=>//Your item ) | |
Using loadmore | |
RetroListView( hasMore: _hasMore, itemCount: _photos.length, stateType: _isLoading ? InfiniteScrollStateType.loading : _error ? InfiniteScrollStateType.error : InfiniteScrollStateType.loaded, onLoadMore: () => fetchPhotos(), // Implements loadmore itemBuilder: (context, index)=>//Your item ), | |
Android style refresh | |
RetroListView( hasMore: _hasMore, itemCount: _photos.length, stateType: _loading ? InfiniteScrollStateType.loading : _error ? InfiniteScrollStateType.error : InfiniteScrollStateType.loaded, onLoadMore: () => fetchPhotos(), // Implements loadmore // To Implement Android Refresh Indicator refreshIndicatorType: RefreshIndicatorType.android, onRefresh: (){ return Future.delayed(Duration(seconds: 2)); }, itemBuilder: (context, index)=>//Your item ) | |
IOS style refresh | |
RetroListView( hasMore: _hasMore, itemCount: _photos.length, physics: BouncingScrollPhysics(), // To be used in if running on Android Devices // and [refreshIndicatorType] // is [RefreshIndicatorType.ios] or [RefreshIndicatorType.custom] stateType: _loading ? InfiniteScrollStateType.loading : _error ? InfiniteScrollStateType.error : InfiniteScrollStateType.loaded, onLoadMore: () => fetchPhotos(), // Implements loadmore // To Implement IOS Sliver refresh indicator refreshIndicatorType: RefreshIndicatorType.ios, onRefresh: (){ return Future.delayed(Duration(seconds: 2)); }, itemBuilder: (context, index)=>//Your item ) | |
Custom error idget | |
RetroListView( hasMore: false, itemCount: _photos.length, stateType: InfiniteScrollStateType.error, errorWidget: Center(child: Text('Some error occurred')), itemBuilder: (ctx, index)=>//Your item }, ) | |
Custom empty widget | |
RetroListView( hasMore: false, itemCount: 0, stateType: InfiniteScrollStateType.loaded, emptyWidget: Center(child: Text('No data found')), itemBuilder: (ctx, index)=>//Your item }, ) |