setDropdownValues function Null safety

void setDropdownValues(
  1. String name,
  2. List values,
  3. [int index = 0]
)

Implementation

void setDropdownValues(String name, List<dynamic> values, [int index = 0]) {
  var elems = getElementsByName(name, index + 1);

  List<String> vals = new List.from(values);

  if (index < elems.length) {
    elems[index].widget?.setState(() {
      elems[index].widget?.values = vals;
      elems[index].widget?.dropdownValue = elems[index].widget?.values[0];
    });
  }
}