Language: English

A simple flutter package for displaying list of items in listview with option to lazy fetch items.

LazyLoadListView provides with 2 different types of options to display Listview rows. LazyLoadListView provides the liberty to the developers to pass their own custom builder to build custom row. The package provides option to lazy fetch data too.

Technical Notes:

The layout for pages is built using Listview.builder . Dev have options show either inbuilt package provided ListTile (Rows) or provide their own designed widgets.

How to use it.

The usage is very simple, just use the following code for default rendering of Listview. By default regularImageListItemType row is displayed.

To just go with default implementaion of LazyLoadListView, Use the following code. Here the row will be of type regularImageListItemType.

    listItems: _herosList,

or use the following code to explore power of LazyLoadListView

    listItems: _herosList,
    listItemType: LazyLoadListViewItemType.largeImageListItemType,
    onListItemTap: _didTapList,
    onScrollDidReachEnd: _loadMorePhotos,
    shouldEndLoad: _shouldEndLoadingPhotos,
    fourthRowPrefixIcon: Icons.location_pin,
    loadingIndicatorColor: Colors.grey,
    endOfListText: 'No more results available',

or use the following with to provide your own custom row / ListTile widget

   listItems: _herosList,
   listItemType: LazyLoadListViewItemType.customListItemType,
   customListItemWidgetBuilder: (_context, _index) {
     final _hero = _herosList[_index];
     return CustomListTile(hero: _hero);
   onScrollDidReachEnd: _loadMorePhotos,
   shouldEndLoad: _shouldEndLoadingPhotos,

Here CustomListTile is simple widget created in example code, You may create any and pass it here.


Parameters for lazy_load_listview

listItemsArray of items data to be rendered as rows in Listview, Use ListItem object to group item details[ListItem]()
shouldEndLoadset the value to true to stop lazy loading of data, Like once you reach end of data from your server or soThis is a optional parameter. value can be true/false
listItemTypeType of List row to be generatedThis is a optional parameter. Pass the type of ListItem to be genrated. Value can be either largeImageListItemType, regularImageListItemType or customListItemType.
onScrollDidReachEndhandler called when list is scrolled to bottom.This is a optional parameter. Pass a method where you can handle your logic for lazy loading.
fourthRowPrefixIconThe fourth row has a optional prefix icon for text. This can be used to represent phone number, location, email etc.This is a optional parameter. Pass IconData type value.
loadingIndicatorColorColor for CircularProgressIndicator for image load or list data loadThis is a optional parameter. Pass Color type value. Default value is Colors.grey
endOfListTextText or String to be shown once fetch reaches its max limit. No more data available after this pointThis is a optional parameter. Default value is "No more results available"
onListItemTapListItem or row click handlerThis is a optional parameter. Pass method to be called on click. Index parameter is returned on click
customListItemWidgetBuilderCustom IndexedWidgetBuilder (Widget Function(BuildContext context, int index)) . Pass your own custom widget, like ListTile, Card or any.This is a optional parameter.

Attributes/Properties of ListItem

firstRowTextString to be displayed in first row Text widgetempty string
secondRowTextString to be displayed in second row Text widgetempty string
thirdRowTextString to be displayed in third row Text widgetempty string
forthRowTextString to be displayed in fourth row Text widgetempty string
imagePathImage path of image, either local assets folder image or http image pathempty string
isLocalImageValue is true if imagePath is local assets folder image, Value is true if imagePath is http image pathtrue

The usage is well described in the example code.

git repo here

Made with ❤ and dedicated with respect to the Saviour Sonu Sood