return MaterialApp(
theme: ThemeData(
brightness: Brightness.light,
// add tabBarTheme
tabBarTheme: const TabBarTheme(
labelColor: Colors.pink[800],
labelStyle: TextStyle(color: Colors.pink[800]), // color for text
indicator: UnderlineTabIndicator( // color for indicator (underline)
borderSide: BorderSide(color: ConstColor.primary))),
primaryColor: Colors.pink[800], // outdated and has no effect to Tabbar
accentColor: Colors.cyan[600] // deprecated,
),
home: DefaultTabController(
length: 3,
child: Scaffold(
appBar: AppBar(
bottom: TabBar(
indicatorColor: Colors.lime,
tabs: [
Tab(icon: Icon(Icons.directions_car)),
Tab(icon: Icon(Icons.directions_transit)),
Tab(icon: Icon(Icons.directions_bike)),
],
),
title: Text('Tabs Demo'),
),
body: TabBarView(
children: [
Icon(Icons.directions_car),
Icon(Icons.directions_transit),
Icon(Icons.directions_bike),
],
),
),
),
);
appBar: AppBar(
brightness: Brightness.dark,
iconTheme: IconThemeData(color: Colors.white),
title: Text("Title TabBar"),
)
TabBar get _tabBar => TabBar(
tabs: [
Tab(icon: Icon(Icons.call)),
Tab(icon: Icon(Icons.message)),
],
);
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
title: Text('AppBar'),
bottom: PreferredSize(
preferredSize: _tabBar.preferredSize,
child: ColoredBox(
color: Colors.red,
child: _tabBar,
),
),
),
),
);
}