Tabbar Step 3, 4 and 5:

Step 3: Next, we need to create a DefaultTabController. The DefaultTabController creates a TabController and makes it available to all widgets.

 

DefaultTabController(  
  // The number of tabs to display.  
  length: 2,  
  child: // Complete this code in the next step.  
); 

In the above code, the length property tells about the number of tabs used in the app.

Step 4: Create the tab. We can create tabs by using the TabBar widget as below code.

DefaultTabController(  
  length: 2,  
  child: Scaffold(  
    appBar: AppBar(  
      bottom: TabBar(  
        tabs: [  
          Tab(icon: Icon(Icons.directions_car)),  
          Tab(icon: Icon(Icons.directions_bike)),  
        ],  
      ),  
    ),  
  ),  
);  

Step 5: Create content for each tab so that when a tab is selected, it displays the content. For this purpose, we have to use the TabBarView widget as:

TabBarView(  
  children: [  
  ],  
);  

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *