'I am trying to use tab controller in flutter how can I access it inside the build context
Solution 1:[1]
Just declare the tabController globally inside your state class and initialise it inside init state as you did, then you can access it inside your build method.
late TabController tabController;
void initState(){
tabController=TabController(vsync:this,length:3);
}
now use accordingly tab controller inside build method.
Solution 2:[2]
Try to declare tabController globally inside your state class and init it inside init state see the documentation for more details :
class _JobApplication... extendes State<...> ..{
late TabController _tabController;
@override
void initState() {
super.initState();
_tabController = TabController(vsync: this, length: 3);
}
}
Solution 3:[3]
declare in state
late TabController _tabController;
Assign in initstate
@override
void initState() {
super.initState();
_tabController = TabController(vsync: this, length: 3);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Ged Flod |
| Solution 3 | MohammedAli |

