icemanbsi / searchable_dropdown

MIT License
107 stars 162 forks source link

Is it possible to hide the selected items below SearchableDropdown.multiple? #124

Closed raLaaaa closed 3 years ago

raLaaaa commented 3 years ago

See my screenshot:

image

I would like to hide blockchain and know-how and only show the dropdown field with the last selected item? Is that possible? I couldnt find an attribute for this.

Thank you!

lcuis commented 3 years ago

Hello @raLaaaa ,

If you want to display only the last selected item, you can use the selectedAggregateWidgetFn for the searchable_dropdown or the search_choices plugin (example for search_choices):

SearchChoices.multiple(
        items: items,
        selectedItems: selectedItemsMultiDialog,
        onChanged: (value) {
          setState(() {
            selectedItemsMultiDialog = value;
          });
        },
        isExpanded: true,
        selectedAggregateWidgetFn: (List<Widget> list) {
          return (list.isNotEmpty?list.last:SizedBox.shrink());
        },
      )

image image

If you want to display the number of selected items instead of the selected items forboth plugins, you can use the same parameters as in below example:

SearchChoices.multiple(
        items: items,
        selectedItems: selectedItemsMultiDialog,
        onChanged: (value) {
          setState(() {
            selectedItemsMultiDialog = value;
          });
        },
        isExpanded: true,
        selectedAggregateWidgetFn: (List<Widget> list) {
          return (Text("${list.length} items selected"));
        },
      )

image

raLaaaa commented 3 years ago

Thank you!

lcuis commented 3 years ago

You’re welcome