vm_page_numbers library

A Flutter widget that provides a highly customizable and responsive pagination UI.

The VmPageNumbers widget creates a row of page numbers with optional previous/next buttons and ellipsis separators for large page ranges. It automatically adapts to the available width by showing/hiding page numbers and adding separators when needed.

Key features:

  • Responsive layout adaptation
  • Smart pagination algorithm
  • Material Design 3 integration
  • Fully customizable appearance
  • Keyboard navigation support
  • High-performance render object implementation

Example usage:

VmPageNumbers(
  currentPage: 5,
  totalPages: 10,
  onPageSelected: (page) {
    setState(() => _currentPage = page);
  },
  // Customize spacing
  navNumberSpacing: 8.0,
  numberNumberSpacing: 4.0,
)

Advanced customization:

VmPageNumbers(
  currentPage: currentPage,
  totalPages: totalPages,
  onPageSelected: onPageSelected,
  // Custom number button appearance
  numberButtonBuilder: (context, page, isCurrent) {
    return CustomButton(
      page: page,
      isSelected: isCurrent,
    );
  },
  // Custom navigation buttons
  previousButtonBuilder: (context, isEnabled, onPressed) {
    return CustomPrevButton(
      onPressed: isEnabled ? onPressed : null,
    );
  },
  nextButtonBuilder: (context, isEnabled, onPressed) {
    return CustomNextButton(
      onPressed: isEnabled ? onPressed : null,
    );
  },
  // Custom separator appearance
  separatorBuilder: (context) {
    return CustomSeparator(),
  },
)

The widget handles these key aspects:

  1. Layout Adaptation:

    • Automatically fits within available width
    • Maintains visual balance and readability
    • Preserves context around current page
  2. Navigation:

    • Previous/Next buttons for sequential navigation
    • Direct page selection
    • Keyboard accessibility
  3. Visual Feedback:

    • Clear indication of current page
    • Disabled state for navigation limits
    • Material Design 3 theming support

See also:

Classes

RenderVmPageNumbers
VmPageNumbers
Creates a page numbers navigation widget.
VmPageNumbersParentData

Typedefs

PageNumberBuilder = Widget Function(BuildContext context, int pageNumber, bool isCurrent)
SeparatorBuilder = Widget Function(BuildContext context)