oi-narendra / multiselect-dropdown

Streamlined Flutter widget for versatile multi-selection with extensive customization.
https://pub.dev/packages/multi_dropdown
GNU General Public License v3.0
74 stars 84 forks source link

Changing Suffix Icon and onTap Action Based on Selected Items State #114

Closed dkdanish98 closed 4 months ago

dkdanish98 commented 4 months ago

Description: I am working on a custom MultiDropdown widget in Flutter. I want to dynamically change the suffix icon and its onTap action when _dropdownController.selectedItems is not empty. Currently, this is the following code:

if (_dropdownController.selectedItems.isNotEmpty) {
  return GestureDetector(
    child: const Icon(Icons.clear),
    onTap: () {
      _dropdownController.clearAll();
      _formFieldKey.currentState?.didChange(_dropdownController.selectedItems);
    },
  );
}

Problem: I want to modify the suffix icon (Icons.clear) and its onTap action based on the state of _dropdownController.selectedItems.isNotEmpty. However, I am not sure how to properly implement this feature in my MultiDropdown widget.

Package-Version: multi_dropdown: ^3.0.0-dev.5

oi-narendra commented 4 months ago

In v3.0.0, suffixIcon now accepts a Widget. Please use it to customize.