next method

Future<CollectionBase<TModel>> next()

If the number of elements is limited by ModelQueryFilterType.limit, additional elements are loaded for the next limited number.

If the number of elements does not change when executed, canNext will be false, but this method will be executed even if canNext is false.

Unlike the load method, this method performs a new load each time it is executed. Therefore, do not use this method in a method that is read repeatedly, such as in the build method of a widget.

ModelQueryFilterType.limitで要素数を制限されている場合、次の制限個数分だけ追加要素を読み込みます。

実行した際に要素数が変わらなかった場合、canNextfalseになりますがこのメソッドはcanNextfalseでも実行されます。

loadメソッドとは違い実行されるたびに新しい読込を行います。そのためWidgetbuildメソッド内など何度でも読み出されるメソッド内では利用しないでください。

Implementation

Future<CollectionBase<TModel>> next() async {
  await _enqueueInternalTransaction(() async {
    _loaded = false;
    _databaseQuery = databaseQuery.copyWith(page: databaseQuery.page + 1);
    final prevLength = length;
    await _load();
    if (length == prevLength) {
      _canNext = false;
      _databaseQuery = databaseQuery.copyWith(page: databaseQuery.page - 1);
    }
  });
  return this;
}