class MultiDropDown extends StatefulWidget {
const MultiDropDown({Key? key}) : super(key: key);
@override
State<MultiDropDown> createState() => _MultiDropDownState();
}
class _MultiDropDownState extends State<MultiDropDown> {
MultiSelectController _controller = MultiSelectController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Home'),
),
body: Column(
children: [
MultiSelectDropDown(
showClearIcon: true,
controller: _controller,
onOptionSelected: (options) {
debugPrint(options.toString());
},
options: const <ValueItem>[
ValueItem(label: 'Option 1', value: '1'),
ValueItem(label: 'Option 2', value: '2'),
ValueItem(label: 'Option 3', value: '3'),
ValueItem(label: 'Option 4', value: '4'),
ValueItem(label: 'Option 5', value: '5'),
ValueItem(label: 'Option 6', value: '6'),
],
selectionType: SelectionType.multi,
chipConfig: const ChipConfig(wrapType: WrapType.scroll),
selectedOptions: [
ValueItem(label: 'Option 5', value: '5'),
ValueItem(label: 'Option 6', value: '6'),
],
selectedItemBuilder: (BuildContext context, List<ValueItem> selectedItems) {
// Implement your logic to build selected items if needed
return Container(child: Text('vgdh'),);
},
dropdownHeight: 300,
optionTextStyle: const TextStyle(fontSize: 16),
selectedOptionIcon: const Icon(Icons.check_circle),
),
],
),
);
}
}
multi_dropdown: ^2.1.2
In this example I want to create a dropdown button by which we can select multiple values at a time.
I also want to show these multiple selected value in the horizontal row.
In this code selected views are visible in horizontal row but recent selected value never come in front. Every time, we have to slide on the screen to view recent selected value or name.
Please help me to fix it
you can modify the selectedItemBuilder method: