list method

Widget list()

Implementation

Widget list() {
  return Expanded(
    child: Scrollbar(
      child: ListView.builder(
        itemBuilder: (context, index) {
          DropdownMenuItem item = widget.items[shownIndexes[index]];
          return InkWell(
            onTap: () {
              if (widget.multipleSelection == true) {
                setState(() {
                  if (widget.selectedItems?.contains(shownIndexes[index]) ==
                      true) {
                    widget.selectedItems?.remove(shownIndexes[index]);
                  } else {
                    widget.selectedItems?.add(shownIndexes[index]);
                  }
                });
              } else {
                widget.selectedItems?.clear();
                widget.selectedItems?.add(shownIndexes[index]);
                if (widget.doneButton == null) {
                  pop();
                } else {
                  setState(() {});
                }
              }
            },
            child: (widget.multipleSelection == true)
                ? widget.displayItem == null
                    ? (Row(children: [
                        Icon(
                          widget.selectedItems
                                      ?.contains(shownIndexes[index]) ==
                                  true
                              ? Icons.check_box
                              : Icons.check_box_outline_blank,
                        ),
                        const SizedBox(
                          width: 7,
                        ),
                        Flexible(child: item),
                      ]))
                    : widget.displayItem?.call(item,
                        widget.selectedItems?.contains(shownIndexes[index]))
                : widget.displayItem == null
                    ? item
                    : widget.displayItem
                        ?.call(item, item.value == selectedResult),
          );
        },
        itemCount: shownIndexes.length,
      ),
    ),
  );
}