Skip to content

Instantly share code, notes, and snippets.

@Hiteshpatel10
Created February 27, 2024 17:11
Show Gist options
  • Save Hiteshpatel10/aa35c524d9b3e2d048185632945c9bb7 to your computer and use it in GitHub Desktop.
Save Hiteshpatel10/aa35c524d9b3e2d048185632945c9bb7 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.
import 'package:flutter/material.dart';
class TabBarThree extends StatelessWidget {
final List<String> tabs;
final bool isScrollable;
final double height;
final TabController? tabController;
final double borderRadius;
const TabBarThree({
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.transparent,
borderRadius: BorderRadius.circular(borderRadius),
border: Border.all(
width: 1,
color: Colors.grey,
),
),
child: TabBar(
dividerColor: Colors.transparent,
isScrollable: isScrollable,
unselectedLabelColor: Colors.black,
labelColor: Colors.white,
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