I want to implement an infinitely scrolling, lazy loading Tik-Tok like social feed using Flutter and auto_route that automatically updates the current navigation route every time I swipe to the next page.
I was planning on using auto_route's AutoTabsRouter.pageView
for this purpose:
AutoTabsRouter.pageView(
routes: [
BooksTab(),
ProfileTab(),
SettingsTab(),
],
builder: (context, child, _) {
final tabsRouter = AutoTabsRouter.of(context);
return Scaffold(
appBar: AppBar(
title: Text(context.topRoute.name),
leading: AutoLeadingButton()),
body: child,
bottomNavigationBar: BottomNavigationBar(
currentIndex: tabsRouter.activeIndex,
onTap: tabsRouter.setActiveIndex
items: [
BottomNavigationBarItem(label: 'Books',...),
BottomNavigationBarItem(label: 'Profile',...),
BottomNavigationBarItem(label: 'Settings',...),
],
),
),
);
},
);
The problem I'm facing is that AutoTabsRouter.pageView
requires a predetermined number of routes
(whereas I want to provide an itembuilder
and dynamically load new pages based on an index).
Do any of you have an idea of how I can resolve this issue?