Closed lt692 closed 2 years ago
If BottomNavigationBar
adds one, we will too.
It would be really good to be able to controll your bottom bar with controller. Then we could sync TabBarView with SalomonBottomBar
Like we can do in TabBar + TabBarView
example:
class _TabLayoutExampleState extends State<TabLayoutExample>
with TickerProviderStateMixin {
late TabController _tabController;
@override
void initState() {
super.initState();
_tabController = TabController(length: 6, vsync: this);
_tabController.animateTo(2);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
bottom: TabBar(
controller: _tabController,
tabs: [
// Put Tabs here
],
),
title: const Text('Flutter'),
backgroundColor: Colors.teal,
),
body: TabBarView(
controller: _tabController,
children: [
// Put widgets here
],
),
),
);
}
}
so equivalent could be
class _TabLayoutExampleState extends State<TabLayoutExample>
with TickerProviderStateMixin {
late TabController _tabController;
@override
void initState() {
super.initState();
_tabController = TabController(length: 6, vsync: this);
_tabController.animateTo(2);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
bottom: SalomonBottomBar (
controller: _tabController,
items: [
// Put items here
],
),
title: const Text('Flutter'),
backgroundColor: Colors.teal,
),
body: TabBarView(
controller: _tabController,
children: [
// Put widgets here
],
),
),
);
}
}
Try wrapping SalomonBottomBar in an AnimatedBuilder, subscribing to TabController, then drive the index off TabController's page value rounded
Add named parameter controller (like in TabBar widget) that we could prove a custom controller and controll its index.