icemanbsi / searchable_dropdown

MIT License
107 stars 166 forks source link

Triggering the Selection Dialog from another widget #37

Open silviorp opened 4 years ago

silviorp commented 4 years ago

I'd loved how this widget works but would need the option to trigger the Selection Dialog from a button from my own layout. I could use the callOnPop to handle the selected behavior but I'm not sure how to trigger the Dialog with the SearchableDropdown visibility set to false. Is there any suggestion in order to use just the Dialog, without the Search field?

lcuis commented 4 years ago

Hi @shrpereira ,

I don't think there is an easy solution to do exactly what you would like the way you'd like to do it. However, there may be a workaround available. Here is below a code that allowed me to display a custom "Text" widget instead of the button and that, I believe, works just like the button you are talking about:

Text customButton=Text("Custom button for Silvio");
...
SearchableDropdown.multiple(
        items: items,
        selectedItems: selectedItems,
        onChanged: (value) {
          setState(() {
            selectedItems = value;
          });
        },
        hint: customButton,
        selectedValueWidgetFn: (item) {
          return customButton;
        },
        underline: Container(
          height: 1.0,
          padding: const EdgeInsets.only(right: 13.0),
          margin: const EdgeInsets.only(right: 13.0),
          decoration: BoxDecoration(
              border:Border()
          ),
        ),
        icon: null,
        displayClearIcon: false,
        isExpanded: true,
      )