group_button

5.3.4

Flutter custom widget to make a group buttons. Included Radio and CheckBox buttons.

Download archive

Readme

GroupButtonController GroupButtonBuilder GroupButtonOptions

Getting Started

Follow these steps to use this package

Add dependency

dependencies:
  group_button: ^5.3.4

Add import package

import 'package:group_button/group_button.dart';

Easy to use

Simple example of use GroupButton Put this code in your project at an screen and learn how it works 😊

GroupButton(
    isRadio: false,
    onSelected: (index, isSelected) => print('$index button is selected'),
    buttons: ["12:00", "13:00", "14:30", "18:00", "19:00", "21:40"],
)

Controller

Starting from version 4.1.0 You can control your Group Button using the controller

final controller = GroupButtonController();

Column(
  children: [
    GroupButton.checkbox(
      controller: controller,
      buttons: ['12:00', '13:00', '14:00'],
      onSelected: (i, selected) => debugPrint('Button #$i $selected'),
    ),
    TextButton(
      onPressed: () => controller.selectIndex(1),
      child: const Text('Select 1 button'),
    )
  ],
),

Generic button value

In new 5.0.0 version you can set custom buttons value type It can be int, DateTime, double or YourCustomClass Button text will be result of .toString() model method in common button display case

GroupButton<DateTime>(
  buttons: [DateTime(2022, 4, 9), DateTime(2022, 4, 10)],
)

Button builders

Also you can use generic button values with cutsom buttonBuilder In order to turn values into any widget

GroupButton<DateTime>(
  buttons: [DateTime(2022, 4, 9), DateTime(2022, 4, 10)],
  buttonBuilder: (selected, date, context) {
    return Text('${date.year}-${date.month}-${date.day}');
  },
),

In this package, there are four different possibilities for customizing your buttons through builders

  • 1 buttonBuilder It will build a fully custom button based on the value parameter
  • 2 buttonIndexedBuilder same as buttonBuilder. But based on button index.
  • 3 buttonTextBuilder It will replace the text of your button, which is constructed based on the style parameters passed in GroupButtonOptions. The appearance of the button remains the same, but the text is changed. Based on button value.
  • 4 buttonIndexedTextBuilder same as buttonTextBuilder. But based on button index.

Fully Customize

In order to customize your buttons inside GroupButton you can use GroupButtonOptions

GroupButtonOptions(
  selectedShadow: const [],
  selectedTextStyle: TextStyle(
    fontSize: 20,
    color: Colors.pink[900],
  ),
  selectedColor: Colors.pink[100],
  unselectedShadow: const [],
  unselectedColor: Colors.amber[100],
  unselectedTextStyle: TextStyle(
    fontSize: 20,
    color: Colors.amber[900],
  ),
  selectedBorderColor: Colors.pink[900],
  unselectedBorderColor: Colors.amber[900],
  borderRadius: BorderRadius.circular(100),
  spacing: 10,
  runSpacing: 10,
  groupingType: GroupingType.wrap,
  direction: Axis.horizontal,
  buttonHeight: 60,
  buttonWidth: 60,
  mainGroupAlignment: MainGroupAlignment.start,
  crossGroupAlignment: CrossGroupAlignment.start,
  groupRunAlignment: GroupRunAlignment.start,
  textAlign: TextAlign.center,
  textPadding: EdgeInsets.zero,
  alignment: Alignment.center,
  elevation: 0,
),

Examples

You can check more examples of using this package here

For help getting started with 😍 Flutter, view online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Changelog

5.3.4

  • Fix deprecated member 'primary'

Thanks to NeroThroN

5.3.3

  • Remove self linter with flutter_lints
  • Fix linter issues
  • Format files

5.3.2

  • Update sdk version to '>=2.15.0 <4.0.0'

5.3.1

  • Add topics in pubspec.yaml
  • Remove deprecated linter rules

5.3.0

  • Implement buttonIndexedTextBuilder and buttonTextBuilder for building only text of buttons. See more in docs
  • Recreate example host folders

5.2.2

  • INFO Update README badages

5.2.1

  • INFO Compatibility with flutter version under 3.3.0

5.2.0

  • INFO: Make the package compatible with the 3.3.0 Flutter version
  • FIX: Analyser issues

5.1.0

  • BREAKING: idnex -> index change typo fix for onDisablePressed callback Function of GroupButtonController
  • INFO: Examples and code base refactoring

Thanks for anasfik

5.0.1

  • FEAT: Added user friendly example

Thanks for vasilich6107

5.0.0

  • MAIN FEAT: GroupButton<T> now is generic class. Now you can create int, DateTime, double or YourCustomClass typed buttons List for default GroupButton constructor. More here

  • BREAKING: All deprecated by 4.3.0 and 4.6.0 fields was removed from package. More here

  • BREAKING: buttonBuilder from 4.6.0 now build buttons by value The buttonIndexedBuilder took over the past functionality of the buttonBuilder

  • INFO: Updated examples & README

4.8.0

  • FEAT: Added enableIndexes abd disableIndexes methods for controller

Thanks for minhdanh

4.7.0

  • FEAT: Added maxSelected field for setting max selected buttons in checkbox mode

Thanks for gnassro

4.6.0

  • FEAT: Added buttonBuilder field for implementing your own custom buttons
  • FEAT: Added ButtonBuilderExample with Flutter default radio and chackbox buttons via buttonBuilder
  • INFO: Updated examples & README

4.5.0

4.4.0

  • BREAKING: remove GroupButton.checkbox() and GroupButton.radio() constructors from 4.0.0 updates

4.3.0

  • FEAT: Implment GroupButtonOptions model to pass all styles of widget via one field
  • DEPRECATED: All styles fields in default GroupButton constructor now deprecated. In new version of package send it via GroupButtonOptions

List of fields:

  • groupingType
  • direction
  • spacing
  • runSpacing
  • selectedTextStyle
  • unselectedTextStyle
  • selectedColor
  • unselectedColor
  • selectedBorderColor
  • unselectedBorderColor
  • borderRadius
  • selectedShadow
  • unselectedShadow
  • buttonHeight
  • buttonWidth
  • mainGroupAlignment
  • crossGroupAlignment
  • groupRunAlignment
  • textAlign
  • textPadding
  • alignment
  • elevation

4.2.1

  • FIX: deprecated fields

4.2.0

  • FEAT: Add disabled buttons to controller
  • FEAT: Add controller fields initialization in controller constructor
  • INFO: Add deprecatd annotation for selectedButton, selectedButtons and disabledButtons

4.1.1

  • FIX: GroupbuttonController initialization

4.1.0

4.0.0

Thanks for bookyo and mwm0022

3.3.1

  • FIX: fix static analysis issues

3.3.0

Thanks for slavap

3.2.0

3.1.0

  • FEAT: Add runSpacing field ! When [groupingType] is [GroupingType.wrap] this field sets Wrap [runSpacing]
  • BREAKING: Now spacing field is not sets GroupButton items vertical spacing

3.0.1

  • FIX: Remove initial selected button from original widget initialization

3.0.0+1

  • FIX: fix app logo link

3.0.0

  • BREAKING: Implement groupingType field to make different grouping types like Wrap, Column, Row
  • FEAT: Remove default values of styling fields for delegate this to theme
  • refactoring: Make some internal refactoring

2.4.1

  • FIX: fix static analysis issues

2.4.0

  • FEAT: implement runGroupAlignment field for placed buttons runs themselves along the cross axis in a layout.

2.3.0

  • FEAT: implement mainGroupAlignment field for placed buttons in the main axis in a layout.
  • FEAT: implement crossGroupAlignment field for placed buttons along the cross axis in a layout.

2.2.2 - 2021-06-05

  • Create example with using provider as state-manager

2.2.1 - 2021-06-01

  • Update examples in README.md

2.2.0 - 2021-06-01

  • Remove provider dependency
  • Fix fields passing for widget
  • Update selectedButtons field (Now int like index)
  • Add selectedButton field for radio type

2.1.2 - 2021-05-04

  • Fix selectedBorderColor not working exception

2.1.1 - 2021-05-04

  • Fix spacing error issue

2.1.0 - 2021-04-06

  • Add ability for using radio mode without an selected buttons

2.0.0+1 - 2021-04-06

  • Fix static analysis issues

2.0.0 - 2021-04-06

  • Migrate to null-safety commit

1.3.0 - 2021-03-04

  • Migrate from using RaisedButton to ElevatedButton

1.2.0 - 2021-03-03

  • Add width and height fields for buttons

1.1.1 - 2021-02-20

  • Refactor code
  • Add lint package

1.1.0 - 2020-10-19

  • Added ability to set initially selected buttons

1.0.2 - 2020-08-11

  • Create travis & codemagic QA

1.0.1 - 2020-08-11

  • Fix dart analyzer issues, errors and remarks

1.0.0 - 2020-08-11

  • Basic functionality for creating a button group
  • Two models of the group were created:
    • Radio (one selected button)
    • CheckBox (several selected buttons)

0.1.0 - 2020-08-9

  • Initial package skeleton

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add group_button
pubspec.yaml
name: group_button
description: Flutter custom widget to make a group buttons. Included Radio and CheckBox buttons.
version: 5.3.4
homepage: https://github.com/Frezyx/group_button
repository: https://github.com/Frezyx/group_button
issue_tracker: https://github.com/Frezyx/group_button

topics:
  - widget
  - ui
  - button
  - chips
  - selector

environment:
  sdk: '>=2.12.0 <4.0.0'

dependencies:
  flutter:
    sdk: flutter

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^2.0.0

flutter:

Version history

VersionPublishedArchiveSHA-256
1.0.0On demandDownloadf1e2735b…2066a2
1.0.1On demandDownload66bfdde7…db3155
1.0.2On demandDownloadb4f950bc…983c38
1.1.0On demandDownload26e688a5…732485
1.1.1On demandDownloadf38536fa…bbdfba
1.2.0On demandDownloada4013618…c588b5
1.3.0On demandDownloadece47f9c…d92ec9
2.0.0On demandDownload668b7c94…4ebb63
2.0.0+1On demandDownload7e567193…921845
2.1.0On demandDownloadae46cf24…1c6c65
2.1.1On demandDownloadaeae4b28…a83e26
2.1.2On demandDownload29b0d63f…2b600f
2.2.0On demandDownload14cf8a8f…c0a773
2.2.1On demandDownload69289680…5752a5
2.2.2On demandDownload5fd861c8…8198f3
2.3.0On demandDownload875e33b9…148436
2.4.0On demandDownloadfcbd6116…21d5db
2.4.1On demandDownloadb78805a7…eea82b
3.0.0On demandDownloadc7509581…ea2945
3.0.0+1On demandDownload4503edbb…e48fb6
3.0.1On demandDownload47ce918d…2eb809
3.1.0On demandDownloade8485f90…1d78e9
3.2.0On demandDownloadc13a7927…32541b
3.3.0On demandDownloadf25deef2…204d1a
3.3.1On demandDownloadb1463e75…ab3c57
4.0.0On demandDownload61e7b2d9…84f285
4.0.0+1On demandDownload0202d2e5…d3af9a
4.1.0On demandDownloade2b21cc1…25158c
4.1.1On demandDownloadbfc5413f…cf1f93
4.2.0On demandDownload1bb63ffe…2423bf
4.2.1On demandDownloadb244ee71…b65529
4.3.0On demandDownloadce8d49c8…ec7b93
4.4.0On demandDownloadb116d788…f2b4e9
4.5.0On demandDownloade6559249…cb55f9
4.6.0On demandDownload35c851b8…ea6530
4.7.0On demandDownload2e834d8f…5a5b47
4.8.0On demandDownloadaecf5862…ecf5cc
5.0.0On demandDownload2abb61e9…55ab53
5.0.1On demandDownload2d5ef6bb…aed9fd
5.1.0On demandDownload32022a3a…8c46bf
5.2.0-compatibility.1On demandDownload8f4b8320…d33e88
5.2.0On demandDownload831be912…071923
5.2.1-dev.1On demandDownload185f0c78…e712e9
5.2.1On demandDownloadf340ef8f…64db4e
5.2.2On demandDownload5a9b325b…cf4f55
5.3.0On demandDownload1382097b…d89298
5.3.1On demandDownload09532486…552462
5.3.2On demandDownload138270bd…ebb669
5.3.3On demandDownloadc10e4721…8a9106
5.3.4Cached · Upstream SHA-256 matchedDownload0610fcf2…415940

Dependencies

flutter { "sdk": "flutter" }