Closed fjelljager closed 1 year ago
Hi @fjelljager! Thanks.
It's possible to change the selected tab using the controller.selectedIndex
ok? So you can change it in initState
.
@override
void initState() {
super.initState();
tabs.add(TabData(
text: 'Tab 1',
leading: (context, status) => Icon(Icons.star, size: 16),
content: Text('Hello')));
tabs.add(TabData(text: 'Tab 2', content: Text('Hello again')));
_controller = TabbedViewController(tabs);
_controller.selectedIndex = 1; // second tab as initial tab
}
I believe that it's enough for you right?
Hi @caduandrade thank you for the quick reply, it's much appreciated!
I just tried that and it worked perfectly, thank you very much.
I think it would be useful to include this in the documentation if you get the time :)
Firstly I would like to say thank you for your fantastic widget!
I have a situation where the initial tab I would like open is not always the first tab. I could not find an "initial tab" parameter anywhere or a way to change the tab programmatically to achieve the same result. If you have any advice on how best to do this it would be much appreciated, thank you.