ETabBar
A customizable TabBar widget for Flutter that supports custom indicators using any Widget type. Easily create scrollable tabs with icon support and smooth page transitions.
Features
- Custom Widget Indicators: Use any Widget as your tab indicator
- Scrollable Tabs: Support for both fixed and scrollable tab layouts
- Page Integration: Seamless integration with PageView for smooth transitions
- Icon Support: Easily create tabs with icons and text
- Flexible Customization: Control alignment, direction, and appearance
Installation
Add this to your package's pubspec.yaml
file:
dependencies:
e_tab_bar: ^0.0.1
Then run:
flutter pub get
Usage
Basic Example
import 'package:e_tab_bar/e_tab_bar.dart';
import 'package:flutter/material.dart';
// Create a controller
final tabController = ETabBarCntlr();
// Create the tab bar
ETabBar(
cntlr: tabController,
children: [
Container(
width: 50,
height: 40,
alignment: Alignment.center,
child: Text('Tab 1'),
),
Container(
width: 50,
height: 40,
alignment: Alignment.center,
child: Text('Tab 2'),
),
Container(
width: 50,
height: 40,
alignment: Alignment.center,
child: Text('Tab 3'),
),
],
)
With PageView Integration
// Controllers
final tabController = ETabBarCntlr();
final pageController = PageController();
// Tab Bar
ETabBar(
cntlr: tabController,
onTap: (index) => tabController.animateChangePage(pageController, index),
children: [
// Your tab widgets
],
),
// Page View
PageView(
controller: pageController,
onPageChanged: tabController.onPageChanged,
children: [
// Your page content
],
)
Custom Indicator
ETabBar(
cntlr: tabController,
indicator: Container(
height: 4,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(2),
),
),
children: [
// Your tab widgets
],
)
Parameters
Parameter | Type | Description |
---|---|---|
children |
List<Widget> |
The tab widgets to display |
cntlr |
ETabBarCntlr? |
Controller for the tab bar |
indicator |
Widget? |
Custom indicator widget |
isScrollable |
bool |
Whether tabs can scroll horizontally |
mainAxisSize |
MainAxisSize |
How much space to occupy in the main axis |
crossAxisAlignment |
CrossAxisAlignment |
How to align children in the cross axis |
direction |
Axis |
The direction of the tab bar (horizontal or vertical) |
onTap |
ValueChanged<int>? |
Callback when a tab is tapped |
License
This project is licensed under the MIT License - see the LICENSE file for details.