setComponentItems function Null safety

void setComponentItems(
  1. String name,
  2. dynamic itemsString,
  3. [int index = 0]
)

Sets ListView items on annotated ListView Figma element referenced by it's name ListView items (itemsString) are represented as array of JSON objects either as List (i.e. returned from jsonDecode()) or as stringified JSON or as List<Map<String, dynamic>> Each item in the array represents an item in the ListView

Implementation

void setComponentItems(String name, dynamic itemsString, [int index = 0]) {
  List<Map<String, dynamic>> items = parseItems(itemsString);

  var elems = getElementsByName(name, index + 1);
  if (index < elems.length) {
    elems[index].widget?.setState(() {
      elems[index]
          .widget
          ?.items
          ?.replaceRange(0, elems[index].widget.items.length, items);
    });
  }
}