showDialogGroupedCheckbox function Null safety

Future showDialogGroupedCheckbox(
  1. {required BuildContext context,
  2. required Text dialogTitle,
  3. required List<String> itemsTitle,
  4. required List values,
  5. List initialSelectedValues = const [],
  6. bool isDismissible = true,
  7. String cancelDialogText = "Cancel",
  8. String submitDialogText = "Select",
  9. bool isMultiSelection = false}
)

display groupedCheckbox inside dialog context : BuildContext to pop the dialog dialogTitle : Text Widget that describe Title of dialog itemsTitle : list of strings that describe each checkbox values : list of values initialSelectedValues : list of initial values that you want to be selected isDismissible : determine whether this route can be dismissed by tapping the modal barrier cancelDialogText : label for cancelButton submitDialogText : label for submitButton isMultiSelection : enable mutli selection groupedCheckbox

Implementation

Future<dynamic> showDialogGroupedCheckbox({
  required BuildContext context,
  required Text dialogTitle,
  required List<String> itemsTitle,
  required List<dynamic> values,
  List<dynamic> initialSelectedValues = const [],
  bool isDismissible = true,
  String cancelDialogText = "Cancel",
  String submitDialogText = "Select",
  bool isMultiSelection = false,
}) async {
  assert(values.isNotEmpty);
  assert(itemsTitle.isNotEmpty);
  assert(values.length == itemsTitle.length);
  if (initialSelectedValues.isNotEmpty) {
    assert(initialSelectedValues
        .where((element) =>
            !values.map((e) => e.runtimeType).contains(element.runtimeType))
        .isEmpty);
  }
  return showDialog(
      context: context,
      builder: (ctx) {
        return _CoreDialogGroupedCheckbox(
          dialogTitle: dialogTitle,
          values: values,
          itemsTitle: itemsTitle,
          initialSelectedValues: initialSelectedValues,
          cancelDialogText: cancelDialogText,
          submitDialogText: submitDialogText,
          isMultiSelection: isMultiSelection,
        );
      },
      barrierDismissible: isDismissible);
}