Component - Tab navigation
This UI component shows how to switch between different pages using tabs at the bottom of the screen. Each tab displays a different content area when selected, making it easy to organize app sections.
This UI component shows how to switch between different pages using tabs at the bottom of the screen. Each tab displays a different content area when selected, making it easy to organize app sections.
Scaffold ├── AppBar ├── body: TabBarView │ └── children: [HomePage, SearchPage, ProfilePage] └── bottomNavigationBar: TabBar
TabBar in Flutter tab navigation?TabBar is the widget that shows the clickable tabs at the top of the screen.TabBarView shows the content, and DefaultTabController manages the state, but TabBar is what users tap.Tab widget accepts named parameters icon and text for icon and label.DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
bottom: TabBar(
tabs: [Tab(text: 'One'), Tab(text: 'Two')],
),
),
body: TabBarView(
children: [
Center(child: Text('Page One')),
Center(child: Text('Page Two')),
],
),
),
)DefaultTabController(
length: 3,
child: Scaffold(
appBar: AppBar(
bottom: TabBar(
tabs: [Tab(text: 'A'), Tab(text: 'B')],
),
),
body: TabBarView(
children: [
Center(child: Text('Page A')),
Center(child: Text('Page B')),
Center(child: Text('Page C')),
],
),
),
)Pass the test and this pattern moves unknown