Context: I have the current design -shown in a screenshot below - where I implemented the Tab
s statically,
Question: How can we create Tab
s on the fly with dynamic values from a server?
For example, a server sends more than 5 Tab
s.
My current implementation contains an AppBar that supports a TabBar
with Tabs as a list of Widgets
Here's the code snippet for the tab bar:
bottom: TabBar(
labelPadding: EdgeInsets.symmetric(horizontal: 20),
indicatorColor: kDarkColor,
labelColor: kDarkColor,
indicatorWeight: 2,
unselectedLabelColor: Colors.black,
isScrollable: true,
tabs: [
Tab(child: Text('Timeline.mostPopularTab'.tr())),
Tab(child: Text('Timeline.menTab'.tr())),
Tab(child: Text('Timeline.womenTab'.tr())),
Tab(child: Text('Timeline.kidsTab'.tr())),
],
),
TabBar(
tabs: _tabsListFromServer.map((serverTab) => Tab(child: Text(serverTab.title))).toList(),
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With