Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a TabBar with three tabs.
Flutter
TabBar(tabs: [Tab(text: 'Home'), Tab(text: 'Search'), Tab(text: [1])])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a tab label that doesn't match the app design.
✗ Incorrect
The third tab should be labeled 'Profile' to complete the TabBar with three tabs.
2fill in blank
mediumComplete the code to set up a DefaultTabController with 3 tabs.
Flutter
DefaultTabController(length: [1], child: Scaffold()) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Setting length to a number different from the actual tabs count.
✗ Incorrect
The length must be 3 to match the number of tabs in the TabBar.
3fill in blank
hardFix the error in the TabBarView children list to match the number of tabs.
Flutter
TabBarView(children: [Center(child: Text('Home')), Center(child: Text('Search')), Center(child: Text([1]))])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a page content that does not match the tab label.
✗ Incorrect
The third child must correspond to the third tab, which is 'Profile'.
4fill in blank
hardFill both blanks to create a TabBar inside the AppBar with three tabs.
Flutter
AppBar(title: Text('My App'), bottom: [1](tabs: [[2]]))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using BottomNavigationBar instead of TabBar inside AppBar.
✗ Incorrect
The AppBar's bottom property should be a TabBar widget with the list of Tab widgets.
5fill in blank
hardFill the blanks to complete a DefaultTabController with Scaffold, AppBar, and TabBarView.
Flutter
DefaultTabController(length: [1], child: Scaffold(appBar: AppBar(title: Text('Tabs')), body: [2](children: [Center(child: Text('Home')), Center(child: Text('Search')), Center(child: Text('Profile'))])))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using TabBar instead of TabBarView for body content.
✗ Incorrect
Length is 3 for three tabs, body uses TabBarView to show pages.