I'm attempting to get only certain values from a drop-down by hiding a select few. Apparently I cannot go over an array index of 3 or nothing shows up and obviously not below an index of 0. I'm trying to hide the first three choices in the drop-down. Any ideas would be appreciated. Please let me know if you need more information.
The printout:
- Select a choice --disabled
- Choice 1
- Choice 2
- Choice 3
- Choice 4
- Choice 5
Code:
List<Map> _predefinedFilterList;
_predefinedFilterList = jsonObject["jsonResponse"] as List<Map>;
for (Map filterMap in _predefinedFilterList) {
dropDownEl.children.add(new OptionElement(data: filterMap["displayName"]));
print("Test: "+filterMap["displayName"]);
// dropDownEl.children[0].hidden = true;
// dropDownEl.children[1].hidden = true;
// dropDownEl.children[2].hidden = true;
}
This would only go over the items after the 3rd as sublist would remove the first 3 list elements.
_predefinedFilterList.sublist(3).forEach((map) => print(map["displayName"]));
What about just clearing the children and then only add these you want to show?
来源:https://stackoverflow.com/questions/25573216/google-dart-only-show-specific-dropdown-child-elements