title: How to change tab in the Flutter Default Tab Controller?
body: <p>I'm using Flutter Default Tab Controller for shows the tab View. And I need to change the tab while clicking the button, I tried to change tab using setState, but I faild. These are my codes:</p>
  
  <pre><code>   class _TabPageState extends State&lt;TabPage&gt; implements TabView {
    int tabIndex = 0;
  
    @override
    Widget build(BuildContext context) {
      return DefaultTabController(
        length: 4,
        initialIndex: tabIndex,
        child: Scaffold(
          appBar: AppBar(),
          body: TabBarView(
            physics: NeverScrollableScrollPhysics(),
            children: [
              Container(
                color: Colors.green,
                child: Center(
                  child: RaisedButton(
                      child: Text('to Tab 3'),
                      onPressed: () {
                        setState(() {
                          tabIndex = 2;
                        });
                      }),
                ),
              ),
              Container(color: Colors.red),
              Container(color: Colors.yellow),
              Container(color: Colors.cyan),
            ],
          ),
          bottomNavigationBar: TabBar(
            labelColor: Colors.black45,
            tabs: [
              Padding(padding: const EdgeInsets.only(top: 12, bottom: 12), child: Text('green')),
              Padding(padding: const EdgeInsets.only(top: 12, bottom: 12), child: Text('red')),
              Padding(padding: const EdgeInsets.only(top: 12, bottom: 12), child: Text('yellow')),
              Padding(padding: const EdgeInsets.only(top: 12, bottom: 12), child: Text('cyan')),
            ],
          ),
        ),
      );
    }
  }
  </code></pre>