show method

Future<List<T>?> show(
  1. BuildContext context
)

Displays the dialog and returns the selected items.

If loadingDialog is provided, it will be displayed while fetching items. Returns null if no item is selected or fetching items fails.

Implementation

Future<List<T>?> show(BuildContext context) async {
  LoadingDialog loadingDialog = this.loadingDialog ??
      LoadingDialog(message: loadingMessage ?? 'Fetching Data');
  loadingDialog.show(context);

  List<T>? items = await asyncItems.call();

  if (context.mounted) loadingDialog.dismiss(context);

  if (context.mounted && items != null) {
    MultiValuePickerDialog<T> dialog = MultiValuePickerDialog(
      title: title,
      titleWidget: titleWidget,
      titleStyle: titleStyle,
      titleBackgroundColor: titleBackgroundColor,
      items: items,
      itemBuilder: itemBuilder,
      selectedItemBuilder: selectedItemBuilder,
      initialSelectedItems: initialSelectedItems,
      dialogButton: dialogButton,
      initiallyMultiSelectAllItems: initiallyMultiSelectAllItems,
      selectionType: selectionType,
      elevation: elevation,
      dialogWidth: dialogWidth,
      titleHeight: titleHeight,
      dialogBorderRadius: dialogBorderRadius,
      dialogHeight: dialogHeight,
      showSelectedTextWidget: showSelectedTextWidget,
      selectedTextBuilder: selectedTextBuilder,
      selectedTextStyle: selectedTextStyle,
    );

    return await dialog.show(context);
  }

  return null;
}