checkbox_grouped 0.8.1
checkbox_grouped: ^0.8.1 copied to clipboard

Flutter Android iOS Linux macOS web Windows

flutter widget that grouping checkbox, recuperate the actual selection,support multiple selection

checkbox_grouped #

pub GitHub

* grouped (checkbox/radioButton)
* customisable grouped checkbox
* grouped chips
* grouped switch
* recuperate the actual selection
* make multiple selection
* dialogGroupedCheckbox
* list of groupedCheckbox

Getting Started #

checkboxGrouped examples

Installing #

Add the following to your pubspec.yaml file:

dependencies:
	checkbox_grouped: ^0.8.1

Simple Usage #

Creating a basic SimpleGroupedCheckbox

    SimpleGroupedCheckbox<int>(
                    controller: controller,
                    itemsTitle: ["1" ,"2","4","5"],
                    values: [1,2,4,5],
                    activeColor: Colors.red,
                    checkFirstElement: false,
                    multiSelection: false,
                  )

Declare GroupController to get selection and enabled/disabled Items #

GroupController controller = GroupController();

GroupController

PropertiesDescription
isMultipleSelection(bool) enable multiple selection in grouped checkbox (default:false).
initSelectedItem(List) A Initialize list of values that will be selected in grouped.

Get current selection #

final selectedItems = controller.selectedItem;

enabled items #

controller.enabledItemsByValues(List<T> values); 

controller.enabledItemsByTitles(List<String> itemsTitles); 

disable item #

controller.disabledItemsByValues(List<T> values);
controller.disabledItemsByTitles(List<String> items)

NOTICE

  • those method disabledItems and enabledItems has been removed
  • if you are using complex object in values , you need to implement operator == and hashcode

SimpleGroupedCheckbox

PropertiesDescription
controller(required) Group Controller to recuperate selectionItems and disable or enableItems.
activeColorThe color to use when a CheckBox is checked.
itemsTitle(required) A list of strings that describes each checkbox button. Each label must be distinct.
itemsSubTitleA list of strings that describes second Text.
onItemSelectedCallback fire when the user make selection
disableItemsSpecifies which item should be disabled. The strings passed to this must match the Titles
values(required) Values contains in each element.
checkFirstElementmake first element in list checked.
isCirculaireenable to use circulaire checkbox.
isExpandableTitleenable group checkbox to be expandable.
groupTitleText title for group checkbox.
groupTitleStyleTextStyle of title for group checkbox.
helperGroupTitle(bool) hide/show checkbox in title to help all selection or de-selection,use it when you want to disable checkbox in groupTitle default:true.
groupTitleAlignment(Alignment) alignment of group title in group checkbox.

Customisable Checkbox Grouped #

Creating a basic CustomGroupedCheckbox

    CustomGroupedCheckbox<int>(
            controller:customController,
            groupTitle: "Custom GroupedCheckbox",
            itemBuilder: (ctx,index,value,isDisabled){
            return Card(
                child: Row(
                    children: <Widget>[
                        Expanded(
                            child: Align(
                                alignment: Alignment.centerLeft,
                                child: Text("$index"),
                            ),
                        ),
                        Opacity(
                              opacity: v?1:0,
                              child: Icon(Icons.check,
                                color: Colors.green,
                                size: 24,
                              ),
                         ),
                      ],
                   ),
                );
            },
            itemCount: 10,
            values: List<int>.generate(10, (i)=>i),
        )

Declare CustomGroupController to get selection ,enabled/disable items #

 CustomGroupController controller = CustomGroupController();

Get current selection #

final selectedItem = controller.selectedItem;

CustomGroupedCheckbox

PropertiesDescription
controller(required) Custom Group Controller to recuperate selectionItems and disable or enableItems.
groupTitlewidget title for group checkbox.
itemBuilder(required) Called to build children.
values(required) Values contains in each element.
itemCount(required)The total number of children
itemExtentThe extent the children are forced to have in the main axis

Chip grouped Usage #

Creating a basic SimpleGroupedChips

SimpleGroupedChips<int>(
                    controller: controller,
                    values: [1,2,3,4,5,6,7],
                    itemTitle: ["1" ,"2","4","5","6","7"],
                    backgroundColorItem: Colors.black26,
                  )

Declare GroupController to get selection and enabled/disabled Items #

GroupController controller = GroupController();

GroupController

PropertiesDescription
isMultipleSelection(bool) enable multiple selection in grouped checkbox (default:false).
initSelectedItem(List) A Initialize list of values that will be selected in grouped.

Get current selection #

final selectedItems = controller.selectedItem;

enabled items #

controller.enabledItemsByValues(List<T> values); 

controller.enabledItemsByTitles(List<String> itemsTitles); 

disable item #

controller.disabledItemsByValues(List<T> values);
controller.disabledItemsByTitles(List<String> items)

SimpleGroupedChip

PropertiesDescription
controller(required) Group Controller to recuperate selectionItems and disable or enableItems.
itemsTitle(required) A list of strings that describes each chip button. Each label must be distinct.
disabledItemsSpecifies which item should be disabled. The strings passed to this must match the Titles
values(required) Values contains in each element.
onItemSelectedCallback when users make selection or deselection
backgroundColorItemthe background color for each item.
selectedColorItemthe background color to use when item is selected.
textColorthe color to use for each text of item.
selectedTextColorthe color to use for the selected text of item.
selectedIconthe icon to use when item is selected.
isScrollingenable horizontal scrolling.

Switch grouped Usage #

Creating a basic SimpleGroupedSwitch

SimpleGroupedSwitch<int>(
                    controller: controller,
                    values: [1,2,4,5],
                    itemsTitle: ["1 " ,"2 ","4 ","5 ","6","7"],
                    isMutlipleSelection: false,
                  )

Declare GroupController to get selection and enabled/disabled Items #

GroupController controller = GroupController();

GroupController

PropertiesDescription
isMultipleSelection(bool) enable multiple selection in grouped checkbox (default:false).
initSelectedItem(List) A Initialize list of values that will be selected in grouped.

Get current selection #

final selectedItems = controller.selectedItem;

enabled items #

controller.enabledItemsByValues(List<T> values); 

controller.enabledItemsByTitles(List<String> itemsTitles); 

disable item #

controller.disabledItemsByValues(List<T> values);
controller.disabledItemsByTitles(List<String> items)

SimpleGroupedSwitch

PropertiesDescription
controller(required) Group Controller to recuperate selectionItems and disable or enableItems.
itemsTitle(required) A list of strings that describes each chip button. Each label must be distinct.
values(required) Values contains in each element.
disableItemsSpecifies which item should be disabled. The value passed to this must match the values list
onItemSelectedCall when users make selection or deselection

showDialogGroupedCheckbox #

display groupedCheckbox inside dialog return values selected

Creating a basic showDialogGroupedCheckbox

showDialogGroupedCheckbox(
                        context: context,
                        cancelDialogText: "cancel",
                        isMultiSelection: true,
                        itemsTitle: List.generate(15, (index) => "$index"),
                        submitDialogText: "select",
                        dialogTitle:Text("example dialog") ,
                        values: List.generate(15, (index) => index)
                      )

showDialogGroupedCheckbox

PropertiesDescription
dialogTitle(required) Text Widget that describe Title of dialog.
itemsTitle(required) Values contains in each element.
values(required) list of values.
initialSelectedValueslist of initial values that you want to be selected.
isDismissibleenable multiple selection.
cancelDialogText(string) label for cancelButton.
submitDialogText(string) label for submitButton.
isMultiSelectionenable multiple selection.

ListGroupedCheckbox #

display list of groupedCheckbox return all values selected

Declare ListGroupController to get all item selected or get item selected by group index #

ListGroupController controller = ListGroupController();

ListGroupController

PropertiesDescription
isMultipleSelectionPerGroup(List
initSelectedValues(List) A Initialize list of values on each group of checkbox that will be selected in group.

Get current selection #

  • get all selection
final selectedItems = controller.allSelectedItems;
  • get all selection by group
final selectedItems = controller.selectedItemsByGroupIndex(indexGroup);

Creating a basic ListGroupedCheckbox

                ListGroupedCheckbox(
                        controller: listController,
                        groupTitles: List.generate(3, (index) => "groupe $index"),
                        values: List.generate(
                          3,
                          (i) =>
                              List.generate(5, (j) => "${(i + Random().nextInt(100)) * j}"),
                        ),
                        titles: List.generate(
                          3,
                          (i) => List.generate(5, (j) => "Title:$i-$j"),
                        ),
                      )

ListGroupedCheckbox

PropertiesDescription
controller(required) manage the ListGroupedCheckbox.
groupTitles(required)Text title for group checkbox in each groupedCheckbox.
titles(required) A list of list of strings that describes each checkbox button. Each label must be distinct in groupedCheckbox.
values(required) Values contains in each element in each groupedCheckbox.
subTitlesA list of list strings that describes second Text in each groupedChckbox.
onSelectedGroupChangedCallBack to get all selected items when users make select new items or deselect items
disabledValuesA nested list of string ,specifies which item should be disabled in each groupedCheckbox. The strings passed to this must match the Titles

MIT Licences

8
likes
90
pub points
83%
popularity

flutter widget that grouping checkbox, recuperate the actual selection,support multiple selection

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

hamza.mohamedali93@gmail.com

License

MIT (LICENSE)

Dependencies

auto_size_text, flare_flutter, flutter

More

Packages that depend on checkbox_grouped