Flutter package to simplify pagination of list of items from the internet.

Overview

PaginationView

All Contributors

Actions Status pub package pub points style: effective dart License: MIT

Installing

In your pubspec.yaml

dependencies:
  pagination_view: ^2.0.0-nullsafety.0
import 'package:pagination_view/pagination_view.dart';

Basic Usage

      PaginationView<User>(
        preloadedItems: <User>[
          User(faker.person.name(), faker.internet.email()),
          User(faker.person.name(), faker.internet.email()),
        ],
        itemBuilder: (BuildContext context, User user, int index) => ListTile(
          title: Text(user.name),
          subtitle: Text(user.email),
          leading: IconButton(
            icon: Icon(Icons.person),
            onPressed: () => null,
          ),
        ),
        header: Text('Header text'),
        footer: Text('Footer text'),
        paginationViewType: PaginationViewType.listView // optional
        pageFetch: pageFetch,
        onError: (dynamic error) => Center(
          child: Text('Some error occured'),
        ),
        onEmpty: Center(
          child: Text('Sorry! This is empty'),
        ),
        bottomLoader: Center( // optional
          child: CircularProgressIndicator(),
        ),
        initialLoader: Center( // optional
          child: CircularProgressIndicator(),
        ),
      ),

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Saif Allah Khaled

πŸ’»

jezsung

πŸ’»

psredzinski

πŸ’»

Javier Torrus

πŸ’»

Jonjo McKay

πŸ’»

This project follows the all-contributors specification. Contributions of any kind welcome!

Comments
  • How to reset the list?

    How to reset the list?

    First of all, thanks for the project!

    How can I reset the list (initialData)? I do have search input + other filters that I need to apply to the search.

    Thanks again.

    opened by ozasadnyy 12
  • PageFetch Logic.

    PageFetch Logic.

    Hi. Can anyone help me with pagefetch logic, below is my code for the current pagefetch logic. Currently the page number is set as static but i want it to return an empty list on the last page of my Map's length.

    PageFetch: Future<List<User>> pageFetch(int offset) async { print(offset); print(moreRestaurantsMap['data'].length); page = (offset / 4).round(); final Faker faker = Faker(); final List<User> nextUsersList = List.generate( 5, (int index) => User( faker.person.name() + ' - $page$index', faker.internet.email(), ), ); await Future<List<User>>.delayed(Duration(seconds: 1)); return page == 24 ? [] : nextUsersList; }

    Below is the error I receive image

    Total number of restaurants at the backend is 104 but it should not matter as pagefetch should be dynamic and should be able to handle the length properly

    opened by ayaanpathan 11
  • pullToRefresh method not working when pull

    pullToRefresh method not working when pull

    I can't set page variable to 0 and cant print 'refreshed' to console when i pull.Beause of that every time i'm getting next page when im refresh.But i want to refresh all from first page.Am i doing something wrong ?

    fetch and refresh methods

     Future<List<Entry>> fetchPage(int offset) async {
        page++;
        String url = craw.BASE + currentHref + pageText();
        print(url);
        EntryPageModel model = await craw.crawEntryPage(url);
        pageModel = model;
    
        return pageModel.entries;
      }
    
      Future<List<Entry>> refresh(int offset) async {
        print('refreshed');
        page = 0;
        return fetchPage(offset);
      }
    
    
    
    

    This is my pagination_view

    PaginationView<Entry>(
                        key: paginationKey,
                        shrinkWrap: true,
                        separatorBuilder: (context, index) {
                          if (index % 9 == 0 && index != 0)
                            return TextDivider(
                                text: '${(index / 10).round()}. sayfa sonu');
                          else
                            return Divider(color: Colors.white30, thickness: 1);
                        },
                        preloadedItems: [],
                        paginationViewType: PaginationViewType.listView,
                        pageFetch: this.fetchPage,
                        pageRefresh: this.refresh,
                        pullToRefresh: true,
                        onError: (dynamic error) => Center(
                          child: Text('Some error occured'),
                        ),
                        onEmpty: Center(
                          child: Text('Sorry! This is empty'),
                        ),
                        bottomLoader: Center(
                          child: CircularProgressIndicator(),
                        ),
                        itemBuilder: (context, entry, index) {
                          return AnimationConfiguration.staggeredList(
                            position: index,
                            child: SlideAnimation(
                              horizontalOffset: 25,
                              duration: Duration(milliseconds: 100),
                              child: EntryWidget(
                                entry: entry,
                              ),
                            ),
                          );
                        },
                      )
    
    opened by oguzhan2142 9
  • Add refresh

    Add refresh

    I made a refresh feature. You can refresh the page by referring to the PaginationViewState using a global key and can call key.currentState.refresh().

    opened by jezsung 8
  • pagefetch method is called multiple times at once

    pagefetch method is called multiple times at once

    Hi. When i try to scroll down, the pagefetch method gets called multiple times and the backend gets throttled. Is there any way to hit the method only once?

    opened by ayaanpathan 7
  • refresh programmatically

    refresh programmatically

    There is any way to refresh a PaginatedView programmatically ?

    I'm have the pagination_view widget and a form on the same page. When the form is submitted, I need to refetch, to update the list I'm showing with PaginatedView

    Thanks

    opened by smunozp 7
  • RenderSliver issue

    RenderSliver issue

    I have the main UI code which starts from header and the main parent is a gesture Detector widget. After updating to the latest null safety version, I am getting the below error:

    The following assertion was thrown building NotificationListener<ScrollNotification>: A RenderShrinkWrappingViewport expected a child of type RenderSliver but received a child of type RenderRepaintBoundary. RenderObjects expect specific types of children because they coordinate with their children during layout and paint. For example, a RenderSliver cannot be the child of a RenderBox because a RenderSliver does not understand the RenderBox layout protocol. The RenderShrinkWrappingViewport that expected a RenderSliver child was created by: ShrinkWrappingViewport ← IgnorePointer-[GlobalKey#58bb2] ← Semantics ← Listener ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#b659b] ← Listener ← _ScrollableScope ← _ScrollSemantics-[GlobalKey#4bfcf] ← RepaintBoundary ← CustomPaint ← RepaintBoundary ← β‹― The RenderRepaintBoundary that did not match the expected child type was created by: RepaintBoundary ← NotificationListener<ScrollNotification> ← GlowingOverscrollIndicator ← Scrollable ← PrimaryScrollController ← SingleChildScrollView ← ShrinkWrappingViewport ← IgnorePointer-[GlobalKey#58bb2] ← Semantics ← Listener ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#b659b] ← β‹―

    opened by ayaanpathan 6
  • Fix Pull to Refresh

    Fix Pull to Refresh

    1. make make 'AlwaysScrollableScrollPhysics()' by default. so it can pull to refresh although the list / child view is not scrollable
    2. fix onEmpty and on error that can not be pulled to refresh
    opened by anggaaryas 5
  • Pagination view doesn't update with new list data unless i swipe down refresh

    Pagination view doesn't update with new list data unless i swipe down refresh

    Hello, am having a frustrating problem with Pagination View, am retrieving list of movies from my API and displaying them in my pagination view, the data is retrieved in a ChangNotifier class and the pagination view widget is wrapped in a consumer, but the pagination view doesn't load the new data when they arrive, unless i pull down refresh.

    this is a video demo to better describe my problem https://streamable.com/ca8k8g

    I apologize if am making a rookie mistake, am learning flutter and i may have missed a pretty obvious step to setting up this function.

    opened by Ozak93 5
  • automatically execute pageFetch function until get all data

    automatically execute pageFetch function until get all data

    Thanks for the awesome widget; but when I try it inside the SliverToBoxAdapter, it automatically execute pageFetch function until get all data; the same when put it in another ListView, shrinkWrap is set true.

    bug 
    opened by rozone 5
  • bottomLoader visible if list is short

    bottomLoader visible if list is short

    Hello, I was trying to implement this package and I noticed that when I fetch data from an API and the number of data returned is not enough to cover the whole view or enough to have it scroll, it causes the bottomLoader to maintain its visibility. Can you help me, please?

    Here is a screenshot Screenshot_3

    opened by emrade 4
  • Header and footer as list of slivers widgets now

    Header and footer as list of slivers widgets now

    Hi! I faced a situation when it's necessary to have several sliver widgets in header or footer and I didn't find other solution except update this component. Please review it.

    PS Very thanks for this component! It saved a lot of mine time

    opened by AlexSeednov 1
  • Example does not user Sliver for Header/Footer

    Example does not user Sliver for Header/Footer

    Change log for version 2.0.0 details breaking issue where header and footer only accept Sliver Widget. Example code uses Text() Widget. As a result the example code does not run and causes dart framework to crash. Please correct example code.

    I only found this b/c another user in an unrelated Stack Overflow post mentioned not using Sliver in a custom scroll view caused a similar error. Then I stumbled across the change log and made the connection. Other devs may not be so lucky.

    opened by Sheltek 0
  • updated dependencies, README.md and more

    updated dependencies, README.md and more

    Hi there!

    I updated some dependencies. I hope you can create a new release soon since te latest available release on pub.dev required flutter_bloc: 7.*.*

    Fixes #58

    opened by LostInDarkMath 1
  • Suggestion: Expiration for the displayed items

    Suggestion: Expiration for the displayed items

    Hi there!

    I have the issue the elements can occur multiple times in the PaginationView. This is the case if new elements are added to the top of my list in the backend. More detailed steps to explain my problem:

    1. If I open my PaginationeView for the first time, I see the first 15 items like expected (15 is always my limit for API requests). The request is send to my backend with offset=0 and limit = 15.
    2. Waiting some time. Meanwhile, a new item is added in my backend at the top of the list.
    3. Now scrolling down will trigger a second API request with offset=15 and limit=15. PaginationView automatically append both results to a list of 30 items. But in the described scenario an item it duplicated (position 15, last of the first request and position 16, first of second request)

    There might be multiple solutions for this specific problem. I'm not sure what is best practice here. From my point of view, I'd like to have a optional parameter expiration of type Duration which forces the PaginationView to reload the whole list even if it has already loaded many items and the user scrolls down.

    What do you think about this?

    opened by LostInDarkMath 2
Owner
Venkatesh Prasad
Flutter Developer
Venkatesh Prasad
A flutter package to simplify pagination with firestore data πŸ—ƒ

Pagination in Firestore Setup Use the same setup used for cloud_firestore package (or follow this). Usage In your pubspec.yaml dependencies: paginat

Venkatesh Prasad 101 Dec 23, 2022
Flutter package to create list of radio button, by providing a list of objects it can be a String list or list of Map.

Custom Radio Group List Flutter package to create list of radio button, by providing a list of objects it can be a String list or list of Map. Feature

Ashok Kumar Verma 0 Nov 30, 2021
Flutter package that provide selectable items in list like Column

vertical_picker vertical_picker is flutter package that you can use it as item selector. users with this package be able to select item that is in ver

Sajad Rahimi 6 Nov 19, 2022
A basic boilerplate template for starting a Flutter GetX project. GetX, Dio, MVVM, get CLI, Localization, Pagination etc are implemented.

Flutter GetX Template (GetX, Dio, MVVM) This Flutter Template using GetX package for State management, routing and Dependency Injection (bindings). We

Hasan Abdullah 214 Jan 9, 2023
Flutterlistpaginationstacked - Pagination in flutter using Stacked Architecture

Pagination in flutter using Stacked Architecture. Link to Readable Tutorial on H

Ademola Babs 0 May 5, 2022
A pure Dart utility library that checks for an internet connection by opening a socket to a list of specified addresses, each with individual port and timeout. Defaults are provided for convenience.

data_connection_checker A pure Dart utility library that checks for an internet connection by opening a socket to a list of specified addresses, each

Kristiyan Mitev 103 Nov 29, 2022
GetX Architecture for large scale project, This project include - pagination, pull to refresh, localization, network call and advance error handling

GetX Architecture for large scale project, This project include - pagination, pull to refresh, localization, network call and advance error handling

Wai Han Ko 5 Nov 29, 2022
Receipt app to list items on a receipt with AI receipt-interpreter. Made with Flutter by Futhark AS

Receipt Recognizer Summary Extracts data from an image of a receipt, storing it in a structured format. The application is created using Flutter and t

Futhark 2 Dec 15, 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
This a library to simplify isolate thread communication.

This a library to simplify islate thread communication. It abstracts the data transfer between islate and the main thread into a simple channel, and t

吴ζ₯šθ‘‘ 3 Oct 31, 2022
Another breakpoint framework. Aims to simplify as much as possible building adaptive layouts.

Another breakpoint framework. Aims to simplify as much as possible building adaptive layouts. Features Really simple implementation Works with and wit

null 3 Sep 26, 2022
A package help you to make api call and handle error faster, also you can check for internet before call api.

http_solver ##not for production use, only for learning purpose. A package help you to make api call and handle error faster, also you can check for i

Abdelrahman Saed 1 Jun 18, 2020
Bac-App-Flutter - Flutter application where you can read PDF locally or by internet and is saved

Bac App - Flutter Flutter application where you can read PDF locally or by inter

Chakib Ammar Aouchiche 3 Jun 7, 2022
A simple flutter app that downloads a file from the internet, shows a custom-made download progress dialog and saves the file to device's internal storage

http_downloader A simple flutter app that downloads a file from the internet using the http plugin. It has a custom-designed progress dialog which dis

Akora Ing. Debrah Kwesi Buabeng 4 Apr 6, 2021
Push Notification service for anime episodes and news. The episode updates will be based on actual upload on the internet and NOT Japan tv schedule as other apps do.

Quantz Push Notification service for anime episodes and news. Features Sub and dub - get notified with latest anime episodes on the internet. Ongoing

null 18 Nov 21, 2022
Lightweight internet connection test, lookup a domain.

palestine_connection Lightweight internet connection test, lookup Google domain. Part of PalestineDevelopers project Features Periodic internet connec

Palestine Developers 5 Jun 26, 2022
Create a Grid Layout of IoT (Internet of Things) devices in a particular house.

Create a Grid Layout of IoT (Internet of Things) devices in a particular house. Keep it simple to just 4-6 devices. Each device will have an icon on its own. When you press the icon, toggle the image and toggle the text underneath between on and off.

null 0 Dec 30, 2021
A host of best internet casual games for mobile users.

Arcade Plaza An online gaming app. Arcade Plaza is an open source mobile gaming app currently available exclusively on Play Store. Read this article t

Aryaman Godara 25 Dec 29, 2022
πŸ’–A free IoT (Internet of Things) platform and private cloud

??A free IoT (Internet of Things) platform and private cloud

Open IoT Hub(δΊ‘ζ˜“θΏž) 422 Nov 30, 2022