vm_page_numbers 1.0.0+2
vm_page_numbers: ^1.0.0+2 copied to clipboard
A customizable Flutter pagination widget that automatically adapts to available space, providing an intuitive and responsive page navigation interface.
VmPageNumbers #
A highly customizable Flutter widget for pagination that provides an elegant and responsive page number navigation interface.
Features #
- Responsive layout that automatically adapts to available width
- Customizable appearance for all elements (numbers, navigation buttons, separators)
- Smart pagination algorithm that maintains context around the current page
- Support for keyboard navigation
- Material Design 3 default theme
- Highly performant custom render object implementation
Installation #
Add this to your package's pubspec.yaml
file:
dependencies:
vm_page_numbers: ^2.1.2
Usage #
VmPageNumbers(
currentPage: 5,
totalPages: 20,
onPageSelected: (page) {
setState(() => _currentPage = page);
},
)
Customization #
You can customize the appearance of all elements:
VmPageNumbers(
currentPage: currentPage,
totalPages: totalPages,
onPageSelected: onPageSelected,
numberButtonBuilder: (context, page, isCurrent) {
return CustomButton(
page: page,
isSelected: isCurrent,
);
},
previousButtonBuilder: (context, isEnabled, onPressed) {
return CustomNavButton(
icon: Icons.chevron_left,
onPressed: isEnabled ? onPressed : null,
);
},
nextButtonBuilder: (context, isEnabled, onPressed) {
return CustomNavButton(
icon: Icons.chevron_right,
onPressed: isEnabled ? onPressed : null,
);
},
separatorBuilder: (context) {
return const Text('•••');
},
navNumberSpacing: 16.0,
numberNumberSpacing: 8.0,
)
Properties #
currentPage
: The current active page (1-based indexing)totalPages
: Total number of pagesonPageSelected
: Callback when a page number is selectedonPreviousPage
: Optional callback for custom previous page navigationonNextPage
: Optional callback for custom next page navigationnumberButtonBuilder
: Builder for page number buttonspreviousButtonBuilder
: Builder for the previous page buttonnextButtonBuilder
: Builder for the next page buttonseparatorBuilder
: Builder for separator (ellipsis) elementsnavNumberSpacing
: Spacing between navigation buttons and number buttonsnumberNumberSpacing
: Spacing between number buttons
Examples #
See the example folder for a complete sample application.
License #
This project is licensed under the MIT License - see the LICENSE file for details.