title: How to get current tab index in Flutter
body: <p>In flutter implementing a tab layout is easy and straightforward. This is a simple example from the official <a href="https://flutter.io/cookbook/design/tabs/" rel="noreferrer">documentation</a>:</p>
  
  <pre><code>import 'package:flutter/material.dart';
  
  void main() {
    runApp(new TabBarDemo());
  }
  
  class TabBarDemo extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return new MaterialApp(
        home: new DefaultTabController(
          length: 3,
          child: new Scaffold(
            appBar: new AppBar(
              bottom: new TabBar(
                tabs: [
                  new Tab(icon: new Icon(Icons.directions_car)),
                  new Tab(icon: new Icon(Icons.directions_transit)),
                  new Tab(icon: new Icon(Icons.directions_bike)),
                ],
              ),
              title: new Text('Tabs Demo'),
            ),
            body: new TabBarView(
              children: [
                new Icon(Icons.directions_car),
                new Icon(Icons.directions_transit),
                new Icon(Icons.directions_bike),
              ],
            ),
          ),
        ),
      );
    }
  }
  </code></pre>
  
  <p>But here is the thing, I want to get the active tab index so I can apply some logic on certain tabs. I search the documentation but I wasn't able to figure it out. Can you guys help and thanks?</p>