在Flutter中将Set<>
转换为List<String>
时需要帮助
Set<_Filter> _selectedFilters = Set<_Filter>();
final List<_Filter> _filters = [
_Filter('Bee Cattle'),
_Filter('Crops'),
_Filter('Machinery'),
_Filter('Fish'),
_Filter('Sheep'),
_Filter('Cattle Breeds'),
_Filter('Wells'),
_Filter('Farm'),
];
我需要将此Set转换为List<string>
。
答案 0 :(得分:0)
您可以简单地使用Iterable.toList
method,也就是Set.toList
。
final Set<String> set = {'cake', 'cookie'};
final List<String> list = set.toList();