showSelectionScreen static method

Future<List<String>?> showSelectionScreen(
  1. BuildContext context, {
  2. required String title,
  3. required List<String> options,
  4. bool multiSelect = false,
  5. List<String> initialSelection = const <String>[],
  6. String cancelLabel = _cancelLabel,
  7. String confirmLabel = _confirmLabel,
  8. Widget? icon,
  9. bool barrierDismissible = true,
})

Presents a centred M3EDialog with selectable options.

Uses M3ERadio for single selection and M3ECheckbox when multiSelect is true. Both section dividers are enabled. Confirm stays disabled until at least one option is selected; on confirm, returns the selected values (or null if dismissed).

Implementation

static Future<List<String>?> showSelectionScreen(
  BuildContext context, {
  required String title,
  required List<String> options,
  bool multiSelect = false,
  List<String> initialSelection = const <String>[],
  String cancelLabel = _cancelLabel,
  String confirmLabel = _confirmLabel,
  Widget? icon,
  bool barrierDismissible = true,
}) {
  assert(options.isNotEmpty, 'options must not be empty.');
  return show<List<String>>(
    context,
    barrierDismissible: barrierDismissible,
    dialog: _M3ESelectionDialog(
      title: title,
      options: options,
      multiSelect: multiSelect,
      initialSelection: initialSelection,
      cancelLabel: cancelLabel,
      confirmLabel: confirmLabel,
      icon: icon,
    ),
  );
}