I would like to create a dropdown or a list of all free FontAwesomeIcons to allow the user choose the one he/she like more. Also if You write something, the list have to filter the icons(that´s optional).
List<IconData> fontAwesomeIcons = [FontAwesomeIcons.accessibleIcon,FontAwesomeIcons.americanSignLanguageInterpreting,FontAwesomeIcons.assistiveListeningSystems,FontAwesomeIcons.audioDescription,];
Solution 1: Peter Haddad
You can do the following:
DropdownButton<IconData>(
value: dropdownValue,
onChanged: (IconDatanewValue) {
setState(() {
dropdownValue = newValue;
});
},
items: <IconData>[FontAwesomeIcons.accessibleIcon,FontAwesomeIcons.americanSignLanguageInterpreting,FontAwesomeIcons.assistiveListeningSystems,FontAwesomeIcons.audioDescription]
.map<DropdownMenuItem<IconData>>((IconData value) {
return DropdownMenuItem<IconData>(
value: value,
child: Text(value),
);
})
.toList(),
),
The DropdownMenuItem
is a class used to represent the items.
onChanged
is called when the user selects an item.
Check the docs for more information:
https://api.flutter.dev/flutter/material/DropdownButton-class.html