DefaultTabController & TabBar (Flutter Widget of the Week)

Flutter · 248K views · 2020 · 1:08

Open on YouTube

Web developmentUX & UI designSoftware (other)explainer

Why Stack Overflow recommends it

Stack Overflow users link it when answering Flutter questions about tabs, page indicators and bottom-bordered selectors, as a quick official intro to TabBar and TabBarView.

Recommended by 3 people across 3 different months, 2020 to 2023.

What it is

A 68-second entry in the official Flutter team's Widget of the Week series introducing DefaultTabController, TabBar and TabBarView for organizing an app's content into tabs. It is a short, scripted explainer from the Flutter YouTube channel.

What people said

Recommends Thiago Bomfim · 2020-11 · Stack Overflow · on “Flutter using TabBar inside Column instead of AppBar”

You can create your appBar, just need to implement PreferredSizeWidget. You are using tabs in the wrong way. See this video for more information: [this video] And the documentation: [LINK] This code may help you, but i really recommend reading the documentation. void main() => runApp(MaterialApp( home: Home144(), )); class Home144 extends StatelessWidget { @override Widget build(BuildContext context) { return DefaultTabController( length: 3, child: Scaffold( appBar: CustomTabBar(), body: TabBarView(children: [ Container( child: Text("Home Body"), ), Container( child: Text("Articles Body"), ), Container( child: Text("User Body"), ), ])), ); } } class CustomTabBar extends StatelessWidget implements

Recommends Hama Sabah · 2022-08 · Stack Overflow · on “I want to use only the border at the bottom of my flutter toggle buttons”

Do not use a toggle widget, according to the design the best widget to use is TabBar , which by default applies a border only at the bottom, you can also change the color of it: indicatorColor: Colors.red, Here is some resources about TabBar widget: Tab Bar by Mitch Koko [LINK] Flutter Widget of the Week [this video] Official Flutter Documentation [LINK]

Recommends Code on the Rocks · 2023-12 · Stack Overflow · on “Animated page indicator on Flutter”

The built-in TabBar [LINK] widget handles this for you: return DefaultTabController( length: 3, child: Scaffold( appBar: AppBar( title: const Text('test'), actions: const [Icon(Icons.more_horiz)], bottom: const TabBar( tabs: [ Tab( text: 'test', ), Tab( text: 'test', ), Tab(text: 'test'), ], ), ), extendBodyBehindAppBar: true, backgroundColor: Colors.red, ), ); Rather than use a PageView, you can use TabBarView and add your pages inside of it. See the official Widget-of-the-week video here: [this video]