Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

newPage.length > pageSize #83

Open
luis901101 opened this issue Nov 14, 2019 · 2 comments
Open

newPage.length > pageSize #83

luis901101 opened this issue Nov 14, 2019 · 2 comments

Comments

@luis901101
Copy link

luis901101 commented Nov 14, 2019

Currently when a new fetched page length is bigger than pageSize an exception is thrown and the list never gets populated even when the data fetch was success. This is a rare situation but possible in case for example that the API endpoint you are requesting doesn't implement pagination and returns all data in each request.

This is the code currently:

If (length > this.pageSize) {
   _isFetchingNotifier.value = false;
   throw ('Page length ($length) is greater than the maximum size (${this.pageSize})');
}

I agree the new page length can not be bigger than the expected page size, but that doesn't mean the list can't be populated with the fetched data. The list should be populated with the data fetched and hasMoreItems should be set as false to avoid further pagination.

Something like this:

if (length > this.pageSize) {
        this._hasMoreItems = false;
        FlutterError.dumpErrorToConsole(
          FlutterErrorDetails(exception: Exception(
              '''
              Inconsistent page length and page size.
              Page length ($length) is greater than the maximum size (${this.pageSize}).
              This is not allowed in pagination and therefore pagination will stop inmediately
              ''')), forceReport: true
        );
//        throw ('Page length ($length) is greater than the maximum size (${this.pageSize})');
      }
@itelixgithub
Copy link

hey @luis901101
implemented the lirbary yesterday - got the same annoying error.
do you have any hot fix for that ?
if not i'll have to write my own pagination logic.
thanks in advance!

@luis901101
Copy link
Author

You will have to implement your own fix... You can use this library code by doing the fix I recommend above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants