i have a layout that if the index of tabView
is 0, then show a widget in AppBar. i can do it. But, the problem is when you swipe the tabView
fast, the page is bounce.
Can we disable the page bounce? or any other solution? here is my code:
class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin {
TabController _tabController;
int _currentIndex;
@override
void initState() {
super.initState();
_tabController = TabController(length: 3, vsync: this);
_currentIndex = 0;
_tabController.animateTo(_currentIndex);
_tabController.addListener(() {
setState(() {
_currentIndex = _tabController.index;
});
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Page ${_currentIndex}'),
bottom: TabBar(
controller: _tabController,
tabs: [
Tab(text: 'One',),
Tab(text: 'Two',),
Tab(text: 'Three',),
],
),
leading: _currentIndex == 0? Icon(Icons.ac_unit): Container(),
),
body: TabBarView(
controller: _tabController,
children: [
Container(color: Colors.red,),
Container(color: Colors.green,),
Container(color: Colors.blue,),
],
),
);
}
}