Created
February 27, 2024 17:08
-
-
Save Hiteshpatel10/59a340f68e61fa6d4bd865df9bd9c409 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 TabBarOne extends StatelessWidget { | |
const TabBarOne({ | |
super.key, | |
required this.tabs, | |
this.isScrollable = true, | |
this.controller, | |
}); | |
final List<String> tabs; | |
final bool isScrollable; | |
final TabController? controller; | |
@override | |
Widget build(BuildContext context) { | |
return TabBar( | |
controller: controller, | |
indicatorSize: TabBarIndicatorSize.tab, | |
physics: const BouncingScrollPhysics(), | |
isScrollable: isScrollable, | |
indicatorColor: const Color(0xff1A51AA), | |
labelColor: const Color(0xff1A51AA), | |
unselectedLabelColor: Colors.black, | |
tabs: List.generate( | |
tabs.length, | |
(index) => Padding( | |
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 12), | |
child: Text( | |
tabs[index], | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment