Created
February 27, 2024 17:10
-
-
Save Hiteshpatel10/05aae3525088755f8380f38a5938a56c to your computer and use it in GitHub Desktop.
TabBarOne is a stateless widget in Flutter that displays a customizable tab bar. It supports features like scrollability, indicator color, and label colors. The tabs can be controlled by a TabController and can contain dynamic text content.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class TabBarTwo extends StatelessWidget { | |
final List<String> tabs; | |
final bool isScrollable; | |
final double height; | |
final TabController? tabController; | |
final double borderRadius; | |
const TabBarTwo({ | |
Key? key, | |
required this.tabs, | |
this.isScrollable = false, | |
this.height = 45, | |
this.tabController, | |
this.borderRadius = 32, | |
}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
height: height, | |
decoration: BoxDecoration( | |
color: Colors.white, | |
borderRadius: BorderRadius.circular(borderRadius), | |
), | |
child: ClipRRect( | |
borderRadius: BorderRadius.circular(borderRadius), | |
child: Container( | |
decoration: BoxDecoration( | |
color: Colors.white, | |
borderRadius: BorderRadius.circular(borderRadius), | |
), | |
child: TabBar( | |
dividerColor: Colors.transparent, | |
isScrollable: isScrollable, | |
unselectedLabelColor: Colors.black, | |
labelColor: Colors.white, | |
indicatorColor: const Color(0xff1A51AA), | |
indicatorSize: TabBarIndicatorSize.tab, | |
padding: const EdgeInsets.all(6), | |
indicator: BoxDecoration( | |
borderRadius: BorderRadius.circular(borderRadius), | |
color: const Color(0xff1A51AA), | |
), | |
controller: tabController, | |
tabs: List.generate( | |
tabs.length, | |
(index) => Tab( | |
child: Text( | |
tabs[index], | |
), | |
), | |
), | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment