Library to create custom Toggle / Tab on your apps

Overview

Flutter Tab Toggle

Build Status pub package

A Beautiful and Simple Tab/Toggle switch widget. It can be fully customized with desired icons, width, colors, text, corner radius etc. It also maintains selection state.

Getting Started

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  flutter_toggle_tab: "^latestVersion"

Import it:

import 'package:flutter_toggle_tab/flutter_toggle_tab.dart';

Usage Examples

Basic tab/toggle switch

// Here default theme colors are used for activeBgColor, activeFgColor, inactiveBgColor and inactiveFgColor
FlutterToggleTab(  
  // width in percent, to set full width just set to 100  
  width: 90,  
  borderRadius: 30,  
  height: 50,  
  initialIndex:0, 
  selectedColors: [Colors.blue],  
  selectedTextStyle: TextStyle(  
    color: Colors.white,
    fontSize: 18,
    fontWeight: FontWeight.w700),
  unSelectedTextStyle: TextStyle(  
    color: Colors.black87,
    fontSize: 14,
    fontWeight: FontWeight.w500),
  labels: ["Tab A (10)", "Tab B (6)", "Tab C (9)"],  
  selectedLabelIndex: (index) {  
	print("Selected Index $index");
  },  
),

Farmers Market Finder Demo

Basic tab/toggle switch with Icon

FlutterToggleTab(  
  width: 50,  
  borderRadius: 15,  
  initialIndex:0, 
  selectedTextStyle: TextStyle(
    color: Colors.white,
    fontSize: 18,
    fontWeight: FontWeight.w600),
  unSelectedTextStyle: TextStyle(
    color: Colors.blue,
    fontSize: 14,
    fontWeight: FontWeight.w400),
  labels: ["Male","Female"],  
  icons: [Icons.person,Icons.pregnant_woman],  
  selectedLabelIndex: (index) {  
	print("Selected Index $index");
  },  
),

Farmers Market Finder Demo

Basic tab/toggle switch with Icon Only

FlutterToggleTab(  
  width: 40,  
  borderRadius: 15,  
  initialIndex:0, 
  selectedTextStyle: TextStyle(
    color: Colors.white,
    fontSize: 18,
    fontWeight: FontWeight.w600),
  unSelectedTextStyle: TextStyle(
    color: Colors.grey,
    fontSize: 14,
    fontWeight: FontWeight.w400),
  labels: ["",""],  
  icons: [Icons.person,Icons.pregnant_woman], 
  selectedLabelIndex: (index) { 
	print("Selected Index $index");
  },

Farmers Market Finder Demo

Update selected tab Programmatically

var _selectedIndex= 0 // you can change selected with update this 
FlutterToggleTab(  
  width: 40,  
  borderRadius: 15,
  initialIndex:0, 
  selectedIndex: _selectedIndex,  
  selectedTextStyle: TextStyle(
    color: Colors.white,
    fontSize: 18,
    fontWeight: FontWeight.w600),
  unSelectedTextStyle: TextStyle(
    color: Colors.grey,
    fontSize: 14,
    fontWeight: FontWeight.w400),
  labels: ["",""],  
  icons: [Icons.person,Icons.pregnant_woman], 
  selectedLabelIndex: (index) {  
	setState(() {
	  _selectedIndex = index;
	  print("Selected Index $index");
	});
  },

Available Parameters

Param isRequired
List<String> labels Yes
Function(int) selectedLabelIndex Yes
TextStyle selectedTextStyle Yes
TextStyle unSelectedTextStyle Yes
int selectedIndex (listener for index selected) see on example Yes
double width (in Percent of width Screen) default: 100 No
double height (double) default: 45 No
List<IconData> icons (List of IconData) No
double borderRadius (double) default 30 No
List<Color> selectedBackgroundColors default : [ Theme.of(context).primaryColor] No
List<Color> unSelectedBackgroundColors default [ Color(0xffe0e0e0)] No
Alignment begin default : Alignment.topCenter No
Alignment end default : Alignment.bottomCenter No
bool isScroll default : true No
EdgeInsets marginSelected default : EdgeInsets.zero No

Buy me coffee if you love my works โ˜•๏ธ

ko-fi      buymeacoffe      paypal



You might also like...

best flutter / dart practices + Custom Painter + Sliver App Bar + Custom Scrollview

best flutter / dart practices + Custom Painter + Sliver App Bar + Custom Scrollview

Weekly Budget Flutter App A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get yo

Oct 21, 2021

A customizable carousel slider widget in Flutter which supports inifinte scrolling, auto scrolling, custom child widget, custom animations and built-in indicators.

A customizable carousel slider widget in Flutter which supports inifinte scrolling, auto scrolling, custom child widget, custom animations and built-in indicators.

flutter_carousel_widget A customizable carousel slider widget in Flutter. Features Infinite Scroll Custom Child Widget Auto Play Horizontal and Vertic

Nov 26, 2022

Flutter package that provides you custom clippers to help you achieve various custom shapes.

Flutter package that provides you custom clippers to help you achieve various custom shapes.

flutter_custom_clippers Flutter package that provides you custom clippers to help you achieve various custom shapes. Usage To use this plugin, add flu

Dec 23, 2022

FT-Custom-Widget - A Custom Widget Built With Flutter

FT-Custom-Widget - A Custom Widget Built With Flutter

Custom Widget Watch it on YouTube Product Screen Sample when you implement compl

Mar 29, 2022

A customizable carousel slider for Flutter. Supports infinite sliding, custom indicators, and custom animations with many pre-built indicators and animations.

A customizable carousel slider for Flutter. Supports infinite sliding, custom indicators, and custom animations with many pre-built indicators and animations.

Flutter Carousel Slider A customizable carousel slider for flutter Screenshots Installing dependencies: flutter_carousel_slider: ^1.0.8 Demo Demo a

Nov 6, 2022

Flutter custom carousel slider - A carousel slider widget,support custom decoration suitable for news and blog

Flutter custom carousel slider - A carousel slider widget,support custom decoration suitable for news and blog

flutter_custom_carousel_slider A carousel slider Flutter widget, supports custom

Dec 29, 2022

A UI library for easily adding audio waveforms to your apps, with several customization options

A UI library for easily adding audio waveforms to your apps, with several customization options

A UI library for easily adding audio waveforms to your apps, with several custom

Dec 11, 2022

Nexus is a state management library that makes it easy to create and consume your application's reactive data to the user interface.

Nexus ๐Ÿš€ Nexus is a state management library that makes it easy to create and consume your application's reactive data to the user interface. With nex

Sep 7, 2022

A Flutter library aims to help you create animated, simple, and stylish Material Dialogs in your app.

A Flutter library aims to help you create animated,  simple, and stylish Material Dialogs in your app.

Flutter Material Dialogs Flutter Material Dialogs ๐Ÿ“ฑ A Flutter library aims to help you create ๐Ÿ’ช๐Ÿปanimated, ๐Ÿ˜ƒ simple, ๐Ÿ˜Ž stylish Material Dialogs in

Dec 25, 2022
Comments
  • FlutterToggleTab range error

    FlutterToggleTab range error

    Basic implementation: FlutterToggleTab( width: 20, height: 30, borderRadius: 15, initialIndex: 0, selectedTextStyle: TextStyle( color: Colors.white, fontSize: 10, fontWeight: FontWeight.w600), unSelectedTextStyle: TextStyle( color: Colors.grey, fontSize: 10, fontWeight: FontWeight.w400), labels: ["", ""], icons: [Icons.lock_outlined, Icons.lock_open], selectedLabelIndex: (index) { print("Selected Index $index"); }, ),

    Error message:

    Exception caught by widgets library โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• The following RangeError was thrown building: RangeError (index): Invalid value: Not in inclusive range 0..1: 2

    When the exception was thrown, this was the stack #0 List.[] (dart:core-patch/growable_array.dart:254:60) #1 _FlutterToggleTabState.build. (package:flutter_toggle_tab/flutter_toggle_tab.dart:149:62) #2 SliverChildBuilderDelegate.build package:flutter/โ€ฆ/widgets/sliver.dart:455 #3 SliverMultiBoxAdaptorElement._build package:flutter/โ€ฆ/widgets/sliver.dart:1201 #4 SliverMultiBoxAdaptorElement.performRebuild.processElement package:flutter/โ€ฆ/widgets/sliver.dart:1145

    bug 
    opened by kesbeast23 9
  • How to add margin or padding for buttons

    How to add margin or padding for buttons

    I want to provide a margin top and bottom for the buttons but there is no such feature, do you think you can add it? I want it to achieve this design: image

    enhancement 
    opened by VladRoscaDev 1
  • removed print statement

    removed print statement

    The creation of the toggle tab widget prints a line containing "initial 0" during tests. This pollutes the output of my tests which makes them harder to read.

    opened by maxime915 0
Owner
Mudassir
LazyCat Labs
Mudassir
A powerful official extension library of Tab/TabBar/TabView, which support to scroll ancestor or child Tabs when current is overscroll, and set scroll direction and cache extent.

extended_tabs Language: English | ไธญๆ–‡็ฎ€ไฝ“ A powerful official extension library of Tab/TabBar/TabView, which support to scroll ancestor or child Tabs whe

FlutterCandies 185 Dec 13, 2022
A colorful TabBar Flutter library with color animating indicator where each tab has a color. (inspired by SmartNews app)

Flutter Colorful TabBar A colorful TabBar for Flutter where each tab has a color (inspired by SmartNews app). Getting Started Add this to your package

null 8 Jun 17, 2022
A new Flutter package customtoggleswitch is used to toggle a setting between on/off which is true/false respectively Created by suryadevsingh.

CustomToggleSwitch A new Flutter package customtoggleswitch is used to toggle a setting between on/off which is true/false respectively Created by sur

Surya Dev Singh 1 Jun 9, 2020
Add beautiful and trending tab indicators directly to your default Flutter TabBar

Add beautiful and trending tab indicators directly to your default Flutter TabBar. Features ?? Supports Android, iOS, Web Can be directly added to the

Adar 51 Dec 23, 2022
A library that makes it easy for you to create your own custom wizard.

Flutter Wizard Author: Jop Middelkamp A library that makes it easy for you to create your custom wizard. You'll have 100% control over the appearance

Baseflow 13 Dec 2, 2022
A tab bar widget for Flutter ๐Ÿ’™ with point indicator.

flutter_point_tab_bar A tab bar widget with point indicator. Demo Usage TabBar( controller: _tabController, indicator: PointTabIndicator(

Hiแปƒn Lรช 5 Sep 16, 2022
A highly customisable and simple widget for having iOS 13 style tab bars.

cupertino_tabbar A highly customisable and simple widget for having iOS 13 style tab bars. It is highly recommended to read the documentation and run

AliYigitBireroglu 98 Oct 31, 2022
Notched Bottom Tab Bar Example using Flutter Framework

bottom_tab_bar Notched Bottom Tab Bar Example using Flutter Framework Getting Started Flutter tutorial explaining how to create a notched shaped botto

Mahtab Ali 76 Dec 6, 2022
New trick on how to create your own custom icons in flutter with bottom bar navigation

Customized Bottom Navigation Bar in Flutter | Tech With Sam Customized Bottom Navigation Bar in Flutter - Watch on youtube โœŒ โ€‚ App Preview App Screens

Samuel Adekunle 10 Oct 26, 2022
Arisonboardingscreen - Create your custom and beautiful onboarding screens easily with Flutter

Flutter Tutorial - Onboarding UI Screen Create your custom and beautiful onboard

Behruz Hurramov 5 Oct 30, 2022