testing library

Testing utilities for flutter_pagination_pro.

Import this file in your test files (not in production code) to get access to test helpers and custom matchers.

import 'package:flutter_pagination_pro/testing.dart';

void main() {
  test('controller starts loaded', () {
    final controller = testPaginationController<int, String>(
      items: ['a', 'b', 'c'],
      status: PaginationStatus.loaded,
      currentPageKey: 1,
    );

    expect(controller, hasItemCount(3));
    expect(controller, isOnPage(1));
    expect(controller, hasStatus(PaginationStatus.loaded));
  });
}

Classes

PaginationController<K, T>
Controller for managing pagination state with generic page keys.
PaginationState<K, T>
Immutable state object for pagination.

Enums

PaginationStatus
Represents the current status of pagination.

Extensions

PaginationStatusX on PaginationStatus
Extension methods for PaginationStatus.
TestPaginationControllerExtension on PaginationController<K, T>
Extends PaginationController with a test-only factory.

Constants

isPaginationCompleted → const Matcher
Matches a PaginationController that has reached the end of pagination (status is PaginationStatus.completed with no more pages).
isPaginationEmpty → const Matcher
Matches a PaginationController whose items list is empty.

Functions

hasItemCount(int count) → Matcher
Matches a PaginationController whose item list has exactly count items.
hasPaginationError([Object? error]) → Matcher
Matches a PaginationController that currently has an error.
hasStatus(PaginationStatus status) → Matcher
Matches a PaginationController whose status equals the given status.
isOnPage(Object? pageKey) → Matcher
Matches a PaginationController whose currentPageKey equals pageKey.
testPaginationController<K, T>({List<T> items = const [], PaginationStatus status = PaginationStatus.loaded, K? currentPageKey, bool hasMorePages = true, Object? error, int? totalItems}) PaginationController<K, T>
Creates a PaginationController pre-populated with a known state, ideal for widget tests.