Google Dart Only Show Specific DropDown Child Elements

Issue

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;
      }

Solution

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

Answered By – ProTom

Answer Checked By – Mildred Charles (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.