Buttons TabBar

Pub

Open source Flutter package, tabbar where each tab indicator is a toggle button.

Made by Afonso Raposo.

See the full example here

Install and import the package. Then just customize its parameters.

Installation

dependencies:
  flutter:
    sdk: flutter
  buttons_tabbar: ^1.3.1

Screenshots

Default

ButtonsTabBar screen
ButtonsTabBar screen animation

ButtonsTabBar - Examples

Example #1

ButtonsTabBar - Example #1
DefaultTabController(
          length: ...,
          child: Column(
            children: <Widget>[
              ButtonsTabBar(
                backgroundColor: Colors.red,
                tabs: ...,
              ),
              Expanded(
                child: TabBarView(
                  children: ...,
                ),
              ),
            ],
          ),
        )

Example #2

ButtonsTabBar - Example #2
DefaultTabController(
          length: ...,
          child: Column(
            children: <Widget>[
              ButtonsTabBar(
                backgroundColor: Colors.blue[600],
                unselectedBackgroundColor: Colors.white,
                labelStyle:
                    TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
		unselectedLabelStyle: TextStyle(
                    color: Colors.blue[600], fontWeight: FontWeight.bold),
                borderWidth: 1,
                unselectedBorderColor: Colors.blue[600],
                radius: 100,
                tabs: ...,
              ),
              Expanded(
                child: TabBarView(
                  children: ...,
                ),
              ),
            ],
          ),
        )

Example #3

ButtonsTabBar - Example #3
DefaultTabController(
  length: 6,
  child: Column(
    children: <Widget>[
      ButtonsTabBar(
        radius: 12,
        contentPadding: EdgeInsets.symmetric(horizontal: 12),
        borderWidth: 2,
        borderColor: Colors.transparent,
        center: true,
        decoration: BoxDecoration(
          gradient: LinearGradient(
            colors: <Color>[
              Color(0xFF0D47A1),
              Color(0xFF1976D2),
              Color(0xFF42A5F5),
            ],
          ),
        ),
        unselectedLabelStyle: TextStyle(color: Colors.black),
        labelStyle: TextStyle(color: Colors.white),
        height: 56,
        tabs: ...,
      ),
      Expanded(
        child: TabBarView(
          children: ...,
        ),
      ),
    ],
  ),
)

ButtonsTabBar Parameters

ParameterTypeDescriptionDefault
tabsList<Widget>The tabs to display. Typically a list of two or more Tab widgets.@required
controllerTabControllerThis widget's selection and animation state.DefaultTabController.of
durationintThe duration in milliseconds of the transition animation.250
backgroundColorColorThe background color of the button on its selected state.Theme.of(context).accentColor
unselectedBackgroundColorColorThe background color of the button on its unselected state.Colors.grey[300]
decorationBoxDecorationThe BoxDecoration of the button on its selected state.null
unselectedDecorationBoxDecorationThe BoxDecoration of the button on its unselected state.null
borderWidthdoubleThe with of solid Border for each button.0
borderColorColorThe border color of the button on its selected state.Colors.black
unselectedBorderColorColorThe border color of the button on its unselected state. If it's value is null, the Color of borderColor is used.null
labelStyleTextStyleThe TextStyle of the button's Text on its selected state. The color provided on the TextStyle will be used for the Icon's color.TextStyle(color: Colors.white)
unselectedLabelStyleTextStyleThe TextStyle of the button's Text on its unselected state. The color provided on the TextStyle will be used for the Icon's color.TextStyle(color: Colors.black)
physicsScrollPhysicsThe physics used for the ScrollControllerof the tabs list.BouncingScrollPhysics
contentPaddingEdgeInsetsThe EdgeInsets used for the Padding of the buttons' content.EdgeInsets.symmetric(horizontal: 4.0)
buttonMarginEdgeInsetsThe EdgeInsets used for the Margin of the buttons.EdgeInsets.all(4.0)
labelSpacingdoubleThe spacing between the Icon and the Text. If only one of those is provided, no spacing is applied.4.0
radiusdoubleThe value of the BorderRadius.circular applied to each button.7.0
heightdoubleOverride the material TabBar height value.46.0
centerboolCenter the tab buttons.false

Future

If you have any suggestion or problem, let me know and I'll try to improve or fix it.

Versioning

  • v1.3.1 - 26 July 2021
  • v1.3.0 - 25 April 2021
  • v1.2.2 - 25 April 2021
  • v1.2.1 - 28 March 2021
  • v1.2.0 - 16 March 2021
  • v1.1.2 - 03 March 2021
  • v1.1.1 - 07 January 2021
  • v1.1.0 - 06 January 2021
  • v1.0.3 - 01 January 2021
  • v1.0.2+1 - 30 November 2020
  • v1.0.2 - 30 November 2020
  • v1.0.1 - 21 October 2020
  • v1.0.0+1 - 07 August 2020
  • v0.1.2+1 - 02 August 2020
  • v0.1.1+1 - 16 May 2020
  • v0.1.0+2 - 24 April 2020
  • v0.1.0+1 - 24 April 2020

License

GNU General Public License v3.0, see the LICENSE.md file for details.

Libraries

buttons_tabbar