A small library support load infinite for ListView - GridView on Flutter.

Overview

Paging

Pub Package
Star on GitHub style: effective dart MIT License


A Flutter package that supports pagination(load infinite) for ListView, GridView

Demo

DataSource

PageKeyedDataSource

To create a PagingListView or PagingGridView you will need create class which extended from PageKeyedDataSource.

When extended from PageKeyedDataSource, you will need override 2 methods is loadInitial and loadPageAfter.

Output of those function is a Tuple2 with item1 is List is List of data, end item2 is next page index.

Example: if your list start with page index is 0. -> on loadInitial output is Tuple2([...], 1) 1 is next page when load more item.

Example:

class ListViewDataSource extends paging.PageKeyedDataSource<int, Note> {
  NoteRepository noteRepository;

  ListViewDataSource(this.noteRepository);

  @override
  Future<Tuple2<List<Note>, int>> loadInitial(int pageSize) async {
    return Tuple2(await noteRepository.getNotes(0), 1);
  }

  @override
  Future<Tuple2<List<Note>, int>> loadPageAfter(int params, int pageSize) async {
    return Tuple2(await noteRepository.getNotes(params), params + 1);
  }
}

Display on UI

To display on UI, currently you can use PagingListView or PagingGridView.

Example:

      ListViewDataSource dataSource = ListViewDataSource(NoteRepository());

      PagingListView<Note>(
        itemBuilder: (context, data, child) => NoteWidget(data),
        pageDataSource: dataSource,
      ),

You might also like...

Sangre - Sangre streams your backend queries in realtime to your clients minimizing the load via diffs

Sangre Sangre streams your backend queries in realtime to your clients minimizin

Nov 27, 2022

Flutter bloc infinite list - A sample application to learn flutter bloc the correct way

flutter_bloc_infinite_list A sample application to learn flutter bloc the correc

Aug 22, 2022

📜Infinite View Pager widget for Flutter

📜Infinite View Pager widget for Flutter

infinite_view_pager Flutter infinite view pager widget Installation dependencies: infinite_view_pager: ^1.0.0 Example import 'package:infinite_view_

Feb 25, 2022

A customizable carousel slider for Flutter. Supports infinite sliding, custom indicators, and custom animations with many pre-built indicators and animations.

A customizable carousel slider for Flutter. Supports infinite sliding, custom indicators, and custom animations with many pre-built indicators and animations.

Flutter Carousel Slider A customizable carousel slider for flutter Screenshots Installing dependencies: flutter_carousel_slider: ^1.0.8 Demo Demo a

Nov 6, 2022

Internationalized dialog for picking a single month from an infinite list of years.

Internationalized dialog for picking a single month from an infinite list of years.

month_picker_dialog Internationalized material style dialog for picking a single month from an infinite list of years. This package makes use of the i

Nov 30, 2022

This widget automatically scrolls the custom child widget to an infinite loop.

This widget automatically scrolls the custom child widget to an infinite loop.

Scroll Loop Auto Scroll This widget automatically scrolls the custom child widget to an infinite loop. Example Features Infinite Auto Scroll Custom ch

Dec 12, 2022

🌈 Repository for a compass project, basically an App for displaying bank transfers, with API requests, Flag persistence, Infinite Scroll, Error Handling, Unit Tests, Extract Sharing working with SOLID, BLoC and Designer Patterns.

🌈 Repository for a compass project, basically an App for displaying bank transfers, with API requests, Flag persistence, Infinite Scroll, Error Handling, Unit Tests, Extract Sharing working with SOLID, BLoC and Designer Patterns.

💸 Green Bank Aplicação desenvolvida em Flutter com intuito de trabalhar conexão com API, Gerenciamento de estado usando BLoC, Refatoração, Arquitetur

Oct 7, 2022

Spider - A small dart library to generate Assets dart code from assets folder.

Spider - A small dart library to generate Assets dart code from assets folder.

Spider A small dart library to generate Assets dart code from assets folder. It generates dart class with static const variables in it which can be us

Nov 8, 2022

This Country Selector UI Library written by Dart and Fluter and supports three locales with country's name, achieves lazy loading, and country card animation on listview

This Country Selector UI Library written by Dart and Fluter and supports three locales with country's name, achieves lazy loading, and country card animation on listview

Country Selector Widget This Country Selector Widget UI Library written by Dart and Fluter and supports three locales with country's name, achieves la

Nov 15, 2022
Comments
  • Add empty, loading, error builder for gridview, public gridview state

    Add empty, loading, error builder for gridview, public gridview state

    • Add empty, loading, error builder for grid view (Currently, grid view show red screen when data is empty)
    • Public grid view state for further control
    opened by tronghuy5555 0
  • Retry function work incorrectly if the list is empty

    Retry function work incorrectly if the list is empty

      Future<List<D>> loadPage({bool isRefresh = false}) async {
        if ((currentKey == null) || isRefresh) {
          if (_cancelableOperation != null && !_cancelableOperation!.isCompleted)
            _cancelableOperation!.cancel();
          _cancelableOperation = CancelableOperation.fromFuture(loadInitial(pageSize));
          final results = await _cancelableOperation!.valueOrCancellation();
          if (autoDetectEndList) {
            isEndList = ((results?.item1.length ?? 0) < pageSize);
          }
          currentKey = results?.item2;
          return results?.item1 ?? [];
        } else {
          _cancelableOperation =  CancelableOperation.fromFuture(loadPageAfter(currentKey!, pageSize));
          final results = await _cancelableOperation!.valueOrCancellation();
          currentKey = results?.item2;
          if (autoDetectEndList) {
            isEndList = ((results?.item1.length ?? 0) < pageSize);
          }
          return results?.item1 ?? [];
        }
      }
    Step: Empty list -> call retry function
    Expect: loadInitial called
    Actual: loadPageAfter called
    opened by tronghuy5555 0
Owner
Đặng Ngọc Đức
Flutter Developer
Đặng Ngọc Đức
A loading more list which supports ListView,GridView,WaterfallFlow and Slivers.

loading_more_list A loading more list which supports ListView,GridView,WaterfallFlow and Slivers. Language: English | 中文简体 Web demo for LoadingMoreLis

FlutterCandies 292 Dec 19, 2022
A font loader to download, cache and load web fonts in flutter with support for Firebase Cloud Storage.

Dynamic Cached Fonts A simple, easy to use yet customizable font loader to use web fonts. Demo: https://sidrao2006.github.io/dynamic_cached_fonts ?? I

Aneesh Rao 18 Dec 21, 2022
Flutter Bidirectional ListView - ListView with items that can be scrolled in both directions with a fixed item count and scroll boundaries.

Flutter Bidirectional ListView ListView with items that can be scrolled and lazy loaded in up and down direction with a fixed item count and scroll bo

Christoph Rothermel 7 May 30, 2022
A library for widgets that load their content one page (or batch) at a time.

A library for widgets that load their content one page (or batch) at a time (also known as lazy-loading and pagination). Features Load data one page a

null 224 Oct 20, 2022
A ListView that allows you to group list items and support headers like iOS UITableView section.

GroupListView package for Flutter. A ListView that allows you to group list items and support headers like iOS UITableView section. Features List Item

Daniel Ioannou 73 Nov 21, 2022
Flutter GridView Example in a Shopping List Design - day 10

Flutter GridView Example UI Design A part of #flutter100daysofcode. Let's create a beautiful and animated GridView Example UI with Flutter. Watch it o

Mohammad Rahmani 190 Dec 26, 2022
A flutter widget that provides pull-down refresh and pull-up load.

flutter_easyrefresh English | 中文 正如名字一样,EasyRefresh很容易就能在Flutter应用上实现下拉刷新以及上拉加载操作,它支持几乎所有的Flutter控件。它的功能与Android的SmartRefreshLayout很相似,同样也吸取了很多三方库的优点。

KnoYo 3.4k Jan 8, 2023
Flutter dynamically load translation in your app.

Flutter dynamically load translation in your app.

null 1 Apr 4, 2022
Simple flutter package to load and search string.

flutter_text_viewer flutter_text_viewer is a simple text viewer package to load and search text from assets,file. Demo Features Load text from assets/

Kunchok Tashi 3 Dec 15, 2022
A command-line application provide an load optimization solution for flutter web

一个命令行工具,针对flutter web加载慢和缓存问题提供了一套解决方案。 功能 通过大文件分片和资源文件cdn化方式,优化flutter web页面加载慢问题。 通过资源文件hash化,解决浏览器强缓存导致功能无法更新问题。 开始 局部安装 dev_dependencies: flutte

Barry 10 Dec 29, 2022