Pagination constructor
Pagination({})
Creates pagination for total items.
Implementation
Pagination({
required int page,
required int pageSize,
required int total,
int siblingCount = 1,
String? className,
Map<String, Object?> props = const {},
Map<String, Object?> style = const {},
DartStyle? dartStyle,
void Function(Object event, int page)? onChanged,
}) : super(
'nav',
props: mergeComponentProps(
{...props, 'aria-label': props['aria-label'] ?? 'Pagination'},
className: className,
defaultStyle: const {
'display': 'flex',
'align-items': 'center',
'justify-content': 'space-between',
'gap': '12px',
},
dartStyle: dartStyle,
style: style,
),
children: [
FlintElement(
'span',
props: const {
'style': {'font-size': '13px', 'color': '#667085'},
},
children: normalizeChildren(
_summary(page: page, pageSize: pageSize, total: total),
const [],
),
),
FlintElement(
'div',
props: const {
'style': {
'display': 'flex',
'align-items': 'center',
'gap': '6px',
},
},
children: [
_button(
'Previous',
page - 1,
disabled: page <= 1,
onChanged: onChanged,
),
for (final pageNumber in _pages(
page,
pageSize,
total,
siblingCount,
))
_button(
pageNumber.toString(),
pageNumber,
current: pageNumber == page,
onChanged: onChanged,
),
_button(
'Next',
page + 1,
disabled: page >= _pageCount(pageSize, total),
onChanged: onChanged,
),
],
),
],
);