GithubHelp home page GithubHelp logo

afonsocraposo / buttons_tabbar Goto Github PK

View Code? Open in Web Editor NEW
78.0 2.0 26.0 1.29 MB

A Flutter package that implements a TabBar where each label is a toggle button.

Home Page: http://afonsoraposo.com/buttons_tabbar/

License: MIT License

Dart 100.00%
flutter flutter-package flutter-ui flutter-widget dart package ui ui-components ui-design tabbar

buttons_tabbar's Introduction

Buttons TabBar

Pub

Buttons TabBar is an open-source Flutter package that provides a tabbar where each tab indicator is a toggle button. It allows you to create interactive and customizable tab bars for your Flutter applications.

ButtonsTabBar screen animation

Features

✨ Each tab indicator is a toggle button
🎨 Customizable appearance and behavior
πŸ–ŒοΈ Supports various styling options, including background color, border color, label style, icon color, and more
πŸš€ Smooth transition animations
πŸ“± Works like a native TabBar
βš™οΈ Simple and easy to use configuration with a wide range of parameters

Installation

To use Buttons TabBar in your Flutter project, follow these steps:

  1. Add the dependency to your pubspec.yaml file:
dependencies:
  flutter:
    sdk: flutter
  buttons_tabbar: ^1.3.7+1
  1. Run flutter pub get to install the package.

Usage

Import the package in your Dart file and customize the tab bar according to your needs:

import 'package:buttons_tabbar/buttons_tabbar.dart';

DefaultTabController(
  length: ...,
  child: Column(
    children: <Widget>[
      ButtonsTabBar(
        // Customize the appearance and behavior of the tab bar
        backgroundColor: Colors.red,
        borderWidth: 2,
        borderColor: Colors.black,
        labelStyle: TextStyle(
          color: Colors.white,
          fontWeight: FontWeight.bold,
        ),
        unselectedLabelStyle: TextStyle(
          color: Colors.black,
          fontWeight: FontWeight.bold,
        ),
        // Add your tabs here
        tabs: ...,
      ),
      Expanded(
        child: TabBarView(
          children: ...,
        ),
      ),
    ],
  ),
)

Examples

Here are a few examples of how you can use Buttons TabBar:

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: ...,
        ),
      ),
    ],
  ),
)

For more examples, please refer to the example.dart file.

Properties

Below are the properties available for customizing the ButtonsTabBar. For more detailed information, check the API reference.

Property Type Description Default
backgroundColor Color The background color of the button on its selected state. Theme.of(context).accentColor
borderColor Color The border color of the button on its selected state. Colors.black
borderWidth double The width of the solid border for each button. 0
buttonMargin EdgeInsets The EdgeInsets used for the margin of the buttons. EdgeInsets.all(4.0)
center bool Center the tab buttons. false
contentPadding EdgeInsets The EdgeInsets used for the padding of the buttons' content. EdgeInsets.symmetric(horizontal: 4.0)
controller TabController This widget's selection and animation state. DefaultTabController.of
decoration BoxDecoration The BoxDecoration of the button on its selected state. null
duration int The duration in milliseconds of the transition animation. 250
elevation double The value of elevation applied to each button. 0
height double? Override the default height. 46.0
labelSpacing double The spacing between the icon and the text. If only one of those is provided, no spacing is applied. 4.0
labelStyle TextStyle The 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)
onTap void Function(int)? An optional callback that's called when the TabBar is tapped. null
physics ScrollPhysics The physics used for the ScrollController of the tabs list. BouncingScrollPhysics()
radius double The value of the BorderRadius.circular applied to each button. 7.0
splashColor Color? The splash color of the button. null
tabs List<Widget> The tabs to display. Typically a list of two or more Tab widgets. @required
unselectedBackgroundColor Color The background color of the button on its unselected state. Colors.grey[300]
unselectedBorderColor Color The border color of the button on its unselected state. If it's value is null, the Color of borderColor is used. null
unselectedDecoration BoxDecoration The BoxDecoration of the button on its unselected state. null
unselectedLabelStyle TextStyle The 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)

Apps Using Buttons TabBar

Here are some apps that are using Buttons TabBar to create engaging and interactive tab bars:

  1. Spotube - Open source Spotify client that doesn't require Premium nor uses Electron! Available for both desktop & mobile! Spotube

If you are using Buttons TabBar in your app and would like to showcase it here, please let us know. We would be happy to feature your app as well.

Please note that the above apps are provided as examples and may not be actively maintained or associated with the Buttons TabBar package.

Future Development

If you have any suggestions or encounter any issues, feel free to let me know. I am committed to improving and maintaining this package.

License

This package is licensed under the MIT License. For more information, see the LICENSE.md file.

More Information

For more information, visit the Buttons TabBar GitHub repository or the author's website.

buttons_tabbar's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

buttons_tabbar's Issues

Hover decoration doesn't match decoration and unselectedDecoration

Bug Report

Description

When using a decoration to change border radius, the hover decoration doesn't get updated to match.
image
image

Steps to Reproduce

  1. Create a ButtonsTabBar.
  2. Add custom decorations that change the border radius.
  3. Launch the application in chrome.
  4. Hover over the tab.

Expected Behavior

The hover decoration should match the border radius of the applied decoration.

Actual Behavior

The hover decoration defaults to the default value of 4.

Additional Information

It would be nice to just have the decoration exposed for hover so that additional changes could be made.

Code Example

import 'package:buttons_tabbar/buttons_tabbar.dart';
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Example(),
    );
  }
}

class Example extends StatefulWidget {
  const Example({Key? key}) : super(key: key);

  @override
  _ExampleState createState() => _ExampleState();
}

class _ExampleState extends State<Example> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: DefaultTabController(
          length: 3,
          child: Column(
            children: <Widget>[
              ButtonsTabBar(
                decoration: const BoxDecoration(
                  borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(4),
                    topRight: Radius.circular(4),
                    bottomLeft: Radius.circular(4),
                    bottomRight: Radius.zero,
                 ),
                  color: Colors.amber,
                ),
                unselectedDecoration: const BoxDecoration(
                  borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(4),
                    topRight: Radius.circular(4),
                    bottomLeft: Radius.circular(4),
                    bottomRight: Radius.zero,
                   ),
                  color: Colors.white,
                ),
                tabs: const [
                  Tab(
                    icon: Icon(Icons.directions_car),
                    text: "car",
                  ),
                  Tab(
                    icon: Icon(Icons.directions_transit),
                    text: "transit",
                  ),
                  Tab(icon: Icon(Icons.directions_bike)),
                ],
              ),
              const Expanded(
                child: TabBarView(
                  children: <Widget>[
                    Center(
                      child: Icon(Icons.directions_car),
                    ),
                    Center(
                      child: Icon(Icons.directions_transit),
                    ),
                    Center(
                      child: Icon(Icons.directions_bike),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Thank you for reporting this bug! We appreciate your contribution to improving our Flutter package.

ButtonsTabBar does not respond to tabController

Hi, @afonsocraposo thanks for your great package.
I want to confirm before switching. This is my listening event code.
void _onTabChanged() async {
if (_mController.indexIsChanging) {
if (_currentIndex < _mController.index) {
bool? jump = await _openAlertDialog();
if (jump == null) {
setState(() {
_mController.index = _currentIndex;
});
} else {
setState(() {
_currentIndex = _mController.index;
});
}
} else {
setState(() {
_currentIndex = _mController.index;
});
}
}
print("index:${_mController.index}");
}
When I give up switching:_mController.index = _currentIndex, TabBarView responds to the change in tabController.index, but ButtonsTabBar does not respond. When I use the TabBar,it's correct.
Look forward to your reply!

Close icon for web applications

Hi,
Thanks for this clean and useful package.

I want to use this package in a web dashboard where the user can add and delete tabs dynamically, like the ones in Google Chrome.

image

Would it be possible to do the following with TabBarView and ButtonsTabBar?

  1. Add a close icon on each tab and delete the tab bar item and its corresponding view when the icon is clicked.
  2. Add a + icon to the right of the ButtonsTabBar as the last widget and call a callback handler which may be supplied as a parameter so that the user of the package can add a new tab in that handler.

Thanks :)

the last item is not visible

current situation :

116004721-0e566880-a615-11eb-8b0a-eb0c7a75f620.mov

what we need :

116004540-2d082f80-a614-11eb-8fb1-93d3c0f3d88e.mov

my Code : https://pastebin.ubuntu.com/p/PFSSmVx9dW/

appBar: AppBar( brightness: Brightness.dark, title: Text('PRAY'), centerTitle: true, backgroundColor: Color(0xff16112a), bottom: ButtonsTabBar( height: 70, decoration: BoxDecoration( gradient: LinearGradient( colors: <Color>[ Color(0xFF0D47A1), Color(0xFF1976D2), Color(0xFF42A5F5), ], ), ), radius: 100, contentPadding: EdgeInsets.symmetric(horizontal: 30), buttonMargin: EdgeInsets.only(top: 10, bottom: 17, left: 20, right: 10), unselectedBackgroundColor: Color(0xff1c1b20), unselectedLabelStyle: TextStyle(color: Colors.white), labelStyle: TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.w600), controller: _tabController, tabs: newsTabs, ), ),

Not responding to clicking on the bottom text

Hello everyone,

I have an issue that I hope can be resolved. I have divided my tabbar button into two vertical sections. You can refer to the attached image for reference. When I click on the top text "Active," it triggers a response upon tapping. However, if I click on the bottom text, which is the number "2" as shown in the image, there is no response. How can I make the response cover all the entire content of the tabbar button?
Screenshot 2023-06-16 at 01-38-48 Screenshot_1686868604 png (PNG Image 1440 Γ— 2560 pixels) β€” Scaled (26%)

Thank you.

Bounces on setstate

Running into this issue, see video.

Screen.Recording.2021-04-20.at.19.43.53.mov
 Container(
    height: 50,
    child: ButtonsTabBar(
      radius: 30,
      physics: NeverScrollableScrollPhysics(),
      contentPadding: EdgeInsets.only(left: 12, right: 12, top: 5, bottom: 5),
      controller: this.controller,
      labelSpacing: 5,
      backgroundColor: Styles.MAIN_COLOR_ACCENT,
      unselectedBackgroundColor: Styles.MAIN_COLOR_LIGHT,
      unselectedLabelStyle: TextStyle(color: Colors.black),
      labelStyle: TextStyle(color: Colors.white, fontSize: 14),
      tabs: [
        Tab(
          text: "YouTube",
        ),
        Tab(
          text: "Reddit",
        ),
        Tab(
          text: "Twitter",
        ),
      ],
    ),
  ),

I am using this widget inside a vertical listview as one of the children.

onTap function

can you add to ButtonTabBar onTap functionality ? for example onTap is have in TabBar

How to move from a button to another tab?

So i made a button to move to another tab, but i don't know how to move it. Does this package have some trigger or something? Because i can't use Navigator.push or similiar

Generate tab list dynamically, when touch tab return issue

When I generate tab like this,

   List<Tab> _pickys = <Tab>[];

   for(int i = 0; i < _nitemPicky.length; i++) {
    _pickys.add(
       Tab(
         icon: Image.network('$img_url${_nitemPicky[i].imgLinkTb}', width: Du.mw(30), height: Du.mw(30),),
         text: "${_nitemPicky[i].name}",
       ),
     );
   }

or like this,

   List<Tab> _pickys2 = List<Tab>.generate(_nitemPicky.length, (int index3) {
     print(_nitemPicky[index3]);
     return new Tab(
       icon: Image.network('$img_url${_nitemPicky[index3].imgLinkTb}', width: Du.mw(30), height: Du.mw(30),),
       text: "${_nitemPicky[index3].name}",
     );
   });

Generate tab is good.

But when I touch list[1] to list[2]

tapping gonna failed and returned this issue.

I/flutter ( 2283): ══║ EXCEPTION CAUGHT BY GESTURE β•žβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
I/flutter ( 2283): The following NoSuchMethodError was thrown while handling a gesture:
I/flutter ( 2283): The method 'findRenderObject' was called on null.
I/flutter ( 2283): Receiver: null
I/flutter ( 2283): Tried calling: findRenderObject()
I/flutter ( 2283):
I/flutter ( 2283): When the exception was thrown, this was the stack:
I/flutter ( 2283): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
I/flutter ( 2283): #1 _ButtonsTabBarState._scrollTo (package:buttons_tabbar/buttons_tabbar.dart:378:48)
I/flutter ( 2283): #2 _ButtonsTabBarState._setCurrentIndex. (package:buttons_tabbar/buttons_tabbar.dart:336:7)
I/flutter ( 2283): #3 State.setState (package:flutter/src/widgets/framework.dart:1240:30)
I/flutter ( 2283): #4 _ButtonsTabBarState._setCurrentIndex (package:buttons_tabbar/buttons_tabbar.dart:332:5)
I/flutter ( 2283): #5 _ButtonsTabBarState._goToIndex (package:buttons_tabbar/buttons_tabbar.dart:326:7)
I/flutter ( 2283): #6 _ButtonsTabBarState._buildButton. (package:buttons_tabbar/buttons_tabbar.dart:255:11)
I/flutter ( 2283): #7 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:992:19)
I/flutter ( 2283): #8 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:1098:38)
I/flutter ( 2283): #9 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:184:24)
I/flutter ( 2283): #10 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:524:11)
I/flutter ( 2283): #11 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:284:5)
I/flutter ( 2283): #12 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:256:7)
I/flutter ( 2283): #13 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:158:27)
I/flutter ( 2283): #14 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:224:20)
I/flutter ( 2283): #15 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:200:22)
I/flutter ( 2283): #16 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:158:7)
I/flutter ( 2283): #17 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:104:7)
I/flutter ( 2283): #18 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:88:7)
I/flutter ( 2283): #22 _invoke1 (dart:ui/hooks.dart:267:10)
I/flutter ( 2283): #23 _dispatchPointerDataPacket (dart:ui/hooks.dart:176:5)
I/flutter ( 2283): (elided 3 frames from dart:async)
I/flutter ( 2283):
I/flutter ( 2283): Handler: "onTap"
I/flutter ( 2283): Recognizer:
I/flutter ( 2283): TapGestureRecognizer#fbbeb
I/flutter ( 2283): ════════════════════════════════════════════════════════════════════════════════════════════════════

Also, when I generate list statically,
like this.

    List<Tab> tabs = <Tab>[
    Tab(
      icon: Image.asset('assets/circle_you.png', width: Du.mw(30), height: Du.mw(30),),
      text: "김꽃날",
    ),
    Tab(
      icon: Image.asset('assets/circle_you.png', width: Du.mw(30), height: Du.mw(30),),
      text: "ν•˜ν‹°",
    ),
    Tab(
      icon: Image.asset('assets/circle_you.png', width: Du.mw(30), height: Du.mw(30),),
      text: "였ꡬ리",
    ),
    Tab(
      icon: Image.asset('assets/circle_you.png', width: Du.mw(30), height: Du.mw(30),),
      text: "λ―Όμ£Όν‹°λ””",
    ),
    Tab(
      icon: Image.asset('assets/circle_you.png', width: Du.mw(30), height: Du.mw(30),),
      text: "μ˜₯개",
    ),
    Tab(
      icon: Image.asset('assets/circle_you.png', width: Du.mw(30), height: Du.mw(30),),
      text: "지토",
    ),
  ];

No error returned and working properly.

So, I want generate list dynamically.

How can I implement?

the example does not work

running the example gave me the following message:
image

my flutter version:
Flutter 2.0.2 β€’ channel stable β€’ https://github.com/flutter/flutter.git
Framework β€’ revision 8962f6dc68 (2 weeks ago) β€’ 2021-03-11 13:22:20 -0800
Engine β€’ revision 5d8bf811b3
Tools β€’ Dart 2.12.1

[Feature] Display label text on tab selection

Hi, @afonsocraposo thanks for your great package, can you please add a feature to display label text only if the tab is selected, I tried with the current index page like: text: _indexPagCurrent == 0 ? 'My Title' : '', , but this way it doesn't work :( .

Thanks in advance!

If each tab is supported with a fixed width and selected and unselected font color is not affected

Bug Report

Description

[Provide a clear and concise description of the bug you encountered.]

Steps to Reproduce

  1. [Outline the steps to reproduce the bug. Be specific and provide any necessary context or prerequisites.]
  2. [Add additional steps if necessary.]

Expected Behavior

[Describe what you expected to happen.]

Actual Behavior

[Describe what actually happened.]

Additional Information

[Provide any additional information that may be helpful in understanding and reproducing the issue.]

Code Example

[Provide a minimal, complete, and verifiable example that reproduces the issue. Use code blocks to preserve the formatting.]

import 'package:buttons_tabbar/buttons_tabbar.dart';
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Example(),
    );
  }
}

class Example extends StatefulWidget {
  const Example({Key? key}) : super(key: key);

  @override
  _ExampleState createState() => _ExampleState();
}

class _ExampleState extends State<Example> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: DefaultTabController(
          length: 3,
          child: Column(
            children: <Widget>[
              ButtonsTabBar(
                tabs: const [
                  Tab(
                    icon: Icon(Icons.directions_car),
                    text: "car",
                  ),
                  Tab(
                    icon: Icon(Icons.directions_transit),
                    text: "transit",
                  ),
                  Tab(icon: Icon(Icons.directions_bike)),
                ],
              ),
              const Expanded(
                child: TabBarView(
                  children: <Widget>[
                    Center(
                      child: Icon(Icons.directions_car),
                    ),
                    Center(
                      child: Icon(Icons.directions_transit),
                    ),
                    Center(
                      child: Icon(Icons.directions_bike),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Please make sure to include a working example code that can reproduce the bug. You can use the provided code snippet as a starting point.

Thank you for reporting this bug! We appreciate your contribution to improving our Flutter package.

Tab with badge or using custom widgets that do not inherit from `Tab`

Hey there!

Great library you have here!

I would like more customization over the tab design. I was able to do everything I want with the parameters you provided, except for the tab badge.

Basically I want to show a badge on the top right corner.

There are two possible solutions for this:

Use onTabChangedListener or similar

Hi, thanks for the package!

What is the correct way to provide a listener to buttons_tabbar that can change some other state? If I need to create a new controller, can you provide an example?

labelStyle text color not work in material3

labelStyle text color not work in material3

Steps to Reproduce

class _ExampleState extends State {
@OverRide
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: DefaultTabController(
length: 3,
child: Column(
children: [
ButtonsTabBar(
labelStyle: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
tabs: const [
Tab(
icon: Icon(Icons.directions_car),
text: "car",
),
Tab(
icon: Icon(Icons.directions_transit),
text: "transit",
),
Tab(icon: Icon(Icons.directions_bike)),
],
),
const Expanded(
child: TabBarView(
children: [
Center(
child: Icon(Icons.directions_car),
),
Center(
child: Icon(Icons.directions_transit),
),
Center(
child: Icon(Icons.directions_bike),
),
],
),
),
],
),
),
),
);
}
}


How to add a shadow under the buttons?

By adding a BoxDecoration property with a BoxShadow property, the shadow stays inside the button block and does not go outside of it. Is it possible to add a property like the elevation property to material objects?
ButtonsTabBar( decoration: BoxDecoration( color: EtalogColors.primary, borderRadius: BorderRadius.circular(50), boxShadow:[ BoxShadow( color: Colors.grey.withOpacity(0.5), spreadRadius: 1, blurRadius: 10, offset: Offset(0, 15), ), //you can set more BoxShadow() here ], ), radius: 0, tabs: [ Tab(text: 'ВсС'), Tab(text: 'Π’ ΠΏΡƒΡ‚ΠΈ'), Tab(text: 'Под Ρ€Π°Π·Π³Ρ€ΡƒΠ·ΠΊΠΎΠΉ'), ], ),

image

TabController initial index not work

Assign a TabController to ButtonsTabBar, but the TabController animateTo(1) and the TabController(initialIndex:1) is not working.

 TabController _tabController;
@override
  void initState() {
    _tabController = TabController(length: 2, vsync: this, initialIndex: 1);
    super.initState();
  }
...
 ButtonsTabBar(
                              controller: _tabController,
...
)

The method 'findRenderObject' was called on null.

I am a Flutter novice, so forgive me if I am doing somethign wrong. I am getting the following error when switching between tabs (all of which build a relatively complex grouped list view). The views show up no problem, but the log will have this error:

The following NoSuchMethodError was thrown while dispatching notifications for TabController:
The method 'findRenderObject' was called on null.
Receiver: null
Tried calling: findRenderObject()

When the exception was thrown, this was the stack: 
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1      _ButtonsTabBarState._scrollTo (package:buttons_tabbar/buttons_tabbar.dart:446:48)
#2      _ButtonsTabBarState._setCurrentIndex (package:buttons_tabbar/buttons_tabbar.dart:405:5)
#3      _ButtonsTabBarState._goToIndex (package:buttons_tabbar/buttons_tabbar.dart:394:7)
#4      _ButtonsTabBarState._handleController (package:buttons_tabbar/buttons_tabbar.dart:264:7)
...
The TabController sending notification was: Instance of 'TabController'

Code that builds the tabs:

  return DefaultTabController(
      length: 9,
      child: Column(
        children: <Widget>[
          ButtonsTabBar(
            contentPadding: EdgeInsets.all(1),
            backgroundColor: Theme.of(context).primaryColor,
            unselectedBackgroundColor: Colors.white,
            labelStyle: TextStyle(color: Colors.white),
            unselectedLabelStyle:
                TextStyle(color: Theme.of(context).primaryColor),
            radius: 50,
            tabs: [
              Tab(
                icon: Icon(
                  FontAwesomeIcons.xxxx,
                ),
                text: "xxxx",
              ),
              Tab(
                icon: Icon(
                  FontAwesomeIcons.xxxx,
                ),
                text: "xxxx",
              ),
              Tab(
                icon: Icon(FontAwesomeIcons.xxxx),
                text: "xxxx",
              ),
              Tab(
                icon: Icon(FontAwesomeIcons.xxxx),
                text: "xxxx",
              ),
              Tab(
                icon: Icon(FontAwesomeIcons.xxxx),
                text: "xxxx",
              ),
              Tab(
                icon: Icon(FontAwesomeIcons.xxxx),
                text: "xxxxx",
              ),
              Tab(
                icon: Icon(FontAwesomeIcons.xxxx),
                text: "xxxx",
              ),
              Tab(
                icon: Icon(FontAwesomeIcons.smile),
                text: "ViselkedΓ©s",
              ),
              Tab(
                icon: Icon(FontAwesomeIcons.questionCircle),
                text: "EgyΓ©b",
              ),
            ],
          ),
          Expanded(
            child: TabBarView(
              children: <Widget>[
                buildListWithFilter(database, null),
                buildListWithFilter(database, 'xxxx'),
                buildListWithFilter(database, 'xxxxx'),
                buildListWithFilter(database, 'xxxxx'),
                buildListWithFilter(database, 'xxxx'),
                buildListWithFilter(database, 'xxxx'),
                buildListWithFilter(database, 'xxxx'),
                buildListWithFilter(database, 'xxxx'),
                buildListWithFilter(database, 'other'),
              ],
            ),
          ),
        ],
      ),
    );
  }



  StreamBuilder<List<Entry>> buildListWithFilter(
      Database database, String entryType) {
    return StreamBuilder<List<Entry>>(
        stream: database.entriesStream(entryType: entryType),
        builder: (context, snapshot) {
          return snapshot.hasData
              ? StickyGroupedListView<dynamic, String>(
                  elements: snapshot.data,
                  groupBy: (dynamic element) =>
                      DateFormat.yMd().format(element.date.toDate()).toString(),
                  separator: _buildSeparator(),
                  groupSeparatorBuilder: (dynamic element) =>
                      _buildGroupSeparator(context, element),
                  itemBuilder: (context, entry) => MainListTile(
                    entry: entry,
                  ),
                  order: StickyGroupedListOrder.DESC, // optional
                )
              : Container();
        });
  }

Any suggestions?

Flutter 3.0.0 is detecting issue with the library

../../../Documents/flutter/.pub-cache/hosted/pub.dartlang.org/buttons_tabbar-1.3.4/lib/buttons_tabbar.dart:180:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.

  • 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../Documents/flutter/packages/flutter/lib/src/widgets/binding.dart').
    WidgetsBinding.instance

labelStyle is not working properly.

ButtonsTabBar( buttonMargin: EdgeInsets.only(left: 25), backgroundColor: Colors.brown[800], unselectedBackgroundColor: Colors.white, unselectedLabelStyle: TextStyle(color: Colors.black), labelStyle: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), radius: 70, labelSpacing: 15, tabs: [ Tab.... )

This is my code which should show White Text on selected Tab and black Text on others. But it just shows black text everywhere. Please, Solve it or provide the solution.

built-in onTap function not available

Hello, I see no onTap function on this lib, use .addListener doesn't work as expected and takes a lot of work for styling. I try to get a callback from the tab button tapped. thanks.

FlutterError - Null check operator used on a null value: _ButtonsTabBarState.initState.<fn>

Bug Report

Description

[Provide a clear and concise description of the bug you encountered.]
I got this error in Firebase Crashlytics

Steps to Reproduce

I do not really not what step to reproduce this issue. This happens on Production release and I see it on Firebase Crashlytics

Expected Behavior

No errors.

Actual Behavior

Got error: FlutterError - Null check operator used on a null value: _ButtonsTabBarState.initState.

Additional Information

[Provide any additional information that may be helpful in understanding and reproducing the issue.]

buttons_tabbar: 1.3.7+1

[!] Flutter (Channel stable, 3.10.6, on macOS 13.2 22D49 darwin-arm64, locale en)
    β€’ Flutter version 3.10.6 on channel stable at /Users/efzet/fvm/versions/3.10.6
    β€’ Upstream repository https://github.com/flutter/flutter.git
    β€’ Framework revision f468f3366c (7 weeks ago), 2023-07-12 15:19:05 -0700
    β€’ Engine revision cdbeda788a
    β€’ Dart version 3.0.6
    β€’ DevTools version 2.23.1
    β€’ If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[βœ“] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    β€’ Android SDK at /Users/efzet/Library/Android/sdk
    β€’ Platform android-33, build-tools 31.0.0
    β€’ ANDROID_HOME = /Users/efzet/Library/Android/sdk
    β€’ Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    β€’ Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    β€’ All Android licenses accepted.

[βœ“] Xcode - develop for iOS and macOS (Xcode 14.2)
    β€’ Xcode at /Applications/Xcode.app/Contents/Developer
    β€’ Build 14C18
    β€’ CocoaPods version 1.12.1

[βœ“] Chrome - develop for the web
    β€’ CHROME_EXECUTABLE = /Applications/Brave Browser.app/Contents/MacOS/Brave Browser

[βœ“] Android Studio (version 2021.3)
    β€’ Android Studio at /Applications/Android Studio.app/Contents
    β€’ Flutter plugin can be installed from:
      πŸ”¨ https://plugins.jetbrains.com/plugin/9212-flutter
    β€’ Dart plugin can be installed from:
      πŸ”¨ https://plugins.jetbrains.com/plugin/6351-dart
    β€’ Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[βœ“] IntelliJ IDEA Ultimate Edition (version 2021.2.4)
    β€’ IntelliJ at /Applications/IntelliJ IDEA.app
    β€’ Flutter plugin version 71.2.2
    β€’ Dart plugin version 212.5744

[βœ“] VS Code (version 1.81.1)
    β€’ VS Code at /Applications/Visual Studio Code.app/Contents
    β€’ Flutter extension version 3.70.0

[βœ“] Connected device (2 available)
    β€’ macOS (desktop) β€’ macos  β€’ darwin-arm64   β€’ macOS 13.2 22D49 darwin-arm64
    β€’ Chrome (web)    β€’ chrome β€’ web-javascript β€’ Brave Browser 116.1.57.53

[βœ“] Network resources
    β€’ All expected network resources are available.

! Doctor found issues in 1 category.

[IMPROVEMENT] Border implementation

Hi, It will be great if we can get border implemented in this package.

Use case example:

unnamed

Maybe we could add something like this in the API:

ButtonsTabBar(
borderWidth: 1.0,
borderColor: Colors.blueAccent,
unselectedBorderWidth: 1.0,
unselectedborderColor: Colors.red,
)

Thanks for your consideration !

No icon in tab

Please add support to having no icon in tab. Now it is possible to use Colors.transparent for icon's color but there is a gap...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.