caduandrade / tabbed_view

Widget inspired by the classic Desktop-style tab component.
MIT License
49 stars 16 forks source link

I don't want to initialize hidden tabs. Do you have any method? please #29

Closed duytient31 closed 1 year ago

caduandrade commented 1 year ago

Hi @duytient31!

Sorry, I do not understand. I don't know if you're talking about the hidden tabs. If so, this is dynamic and only occurs when there is no space for them to be displayed on the screen.

zzt741 commented 1 year ago

I have similar question, when you switch tabs, the tab's widget's states are recreated, causing the page rerendered, how to keep the state?

caduandrade commented 1 year ago

Hi @zzt741 !

Sure! It's the keepAlive (I thought it best to keep the same name used by Flutter)

https://github.com/caduandrade/tabbed_view#keep-alive

    List<TabData> tabs = [];
    tabs.add(TabData(
        text: 'Tab',
        content: Padding(child: Text('Hello'), padding: EdgeInsets.all(8))));
    tabs.add(TabData(
        text: 'TextField',
        content: Padding(
            child: TextField(
                decoration: InputDecoration(
                    isDense: true, border: OutlineInputBorder())),
            padding: EdgeInsets.all(8)),
        keepAlive: true));

    TabbedViewController controller = TabbedViewController(tabs);
    TabbedView tabbedView = TabbedView(controller: controller);

@duytient31 , I'm considering that your question is the same ok?