nextPage method
Navigate to the next page in a journey layout Returns true if navigation was successful, false if already at last page
Implementation
Future<bool> nextPage() async {
// Get current page index
dynamic currentData = Backpack.instance.read('${state}_current_tab');
int currentIndex = (currentData is int) ? currentData : 0;
// Get total pages count (requires storing this value)
dynamic totalPagesData =
await Backpack.instance.read('${state}_total_pages');
int? totalPages = totalPagesData is int ? totalPagesData : null;
// If we don't know total pages, we can't validate if we're at the end
// So we'll just try to navigate to the next page
if (totalPages == null || currentIndex < totalPages - 1) {
updateState(state,
data: {"action": "update-tab", "tab-index": currentIndex + 1});
return true;
}
return false; // Already at last page
}