0

I was used group_button package from flutter to make user can select many options. After upgrading the library to version 5.0.0 or above, the selectedButtons property has been deprecated. I was save options of user by it but no I can't use it now. I was use it as:


  GroupButton(
                      selectedButtons: setSelectedBtn(index),
                      isRadio: false,
                      spacing: 10,
                      onSelected: (i, isSelected) =>
                          onFilterSelect(index, i, isSelected),
                      buttons: widget.filters[index].value
                          .map((e) => e.value)
                          .toList())),




  setSelectedBtn(index) {
    List<int> result = [];
    var valueSet = widget.filters[index].value;
    bool isSelected = valueSet
        .firstWhere((element) => element.isSelected,
            orElse: () => CategoryFilterValues("", false))
        .isSelected;
    if (!isSelected) {
      return result;
    }

    for (int index = 0; index < valueSet.length; index++) {
      if (valueSet.elementAt(index).isSelected) {
        result.add(index);
      }
    }
    return result;
  }

group_button

How I can save the options now in new version? Anyone can help me to do it.

thank you

1 Answer 1

1

Use GroupButtonController. Controller have list of methods to interact with options.

selectIndex(int i) - Select button by index in radio type
unselectIndex(int i) - Unselect button by index in checkbox and radio type
... etc.

More docs and examples you can find here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.