Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to customize selected items container #12

Closed
slavap opened this issue May 19, 2020 · 3 comments
Closed

Ability to customize selected items container #12

slavap opened this issue May 19, 2020 · 3 comments

Comments

@slavap
Copy link

slavap commented May 19, 2020

    Widget innerItemsWidget;
    List<Widget> list = List<Widget>();
    selectedItems?.forEach((item) {
      list.add(widget.selectedValueWidgetFn != null
          ? widget.selectedValueWidgetFn(widget.items[item].value)
          : items[item]);
    });
    if (list.isEmpty && hintIndex != null) {
      innerItemsWidget = items[hintIndex];
    } else {
      innerItemsWidget = Column( // <<< it could be Wrap, Row, ... - make it customizable e.g. selectedValuesStageFn 
        children: list,
      );
    }
@lcuis
Copy link
Owner

lcuis commented May 23, 2020

Hello @slavap ,

Thanks for you proposal.
Here is an example of how to use latest version of the plugin:

SearchChoices.multiple(
        items: items,
        selectedItems: selectedItemsMultiDialogWithCountAndWrap,
        hint: "Select items",
        searchHint: "Select items",
        onChanged: (value) {
          setState(() {
            selectedItemsMultiDialogWithCountAndWrap = value;
          });
        },
        isExpanded: true,
        selectedValueWidgetFn: (item) {
          return (Container(
            margin: const EdgeInsets.all(15.0),
            padding: const EdgeInsets.all(3.0),
            decoration:
                BoxDecoration(border: Border.all(color: Colors.blueAccent)),
            child: Text(
              item,
              overflow: TextOverflow.ellipsis,
            ),
          ));
        },
        selectedAggregateWidgetFn: (List<Widget> list) {
          return (Column(children: [
            Text("${list.length} items selected"),
            Wrap(children: list),
          ]));
        },
      )

Please let me know whether this fulfills your needs.

@slavap
Copy link
Author

slavap commented May 27, 2020

@lcuis Thank you! Works exactly as expected.

@slavap slavap closed this as completed May 27, 2020
@lcuis
Copy link
Owner

lcuis commented May 27, 2020

Thanks for your confirmation @slavap !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants