next method

  1. @override
Future<void> next()
override

Load the data on the next page.

If there is no data, load() is executed.

Implementation

@override
Future<void> next() async {
  try {
    if (!canNext) {
      return;
    }
    final prevLength = length;
    _nextCount = _nextCount + 1;
    if (subscriptions.isNotEmpty) {
      for (final sub in subscriptions) {
        await sub.cancel();
      }
      clear();
      subscriptions.clear();
      await listen();
    } else {
      clear();
      await load();
    }
    if (prevLength == length) {
      _nextCount = _nextCount - 1;
    }
  } catch (e) {
    rethrow;
  }
}