Google Dart Only Show Specific DropDown Child Elements

筅森魡賤 提交于 2019-12-02 22:59:18

问题


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:

  1. Select a choice --disabled
  2. Choice 1
  3. Choice 2
  4. Choice 3
  5. Choice 4
  6. 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;
      }

回答1:


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"]));



回答2:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!