0

I want to go through my List of Strings, and add it to a text element for display, but I want to remove the []. I am using multiselect: ^0.0.4 package.

If the List is.

['S', 'M', 'L', 'XL']

I want to show in the text as - S,M

CODE :-

List<String> selected = [];

  child: DropDownMultiSelect(
    onChanged: (List<String> x) {
      setState(() {
        selected = x;
      });
    },
    options: ['S', 'M', 'L', 'XL'],
    selectedValues: selected,
    whenEmpty: 'Select Size',
  ),

DataCell(Text(
  '$selected ',
  style: const TextStyle(
    color: Colors.white,
    fontSize: 25.0,
  ),
)),
Dren
  • 21
  • 9

1 Answers1

1

It's quite easy:

selected.join(',');
Tim Jacobs
  • 1,023
  • 1
  • 8
  • 14