actionSheet<T> static method

Future<T?> actionSheet<T>({
  1. required List<UNavAction> actions,
  2. String? title,
  3. String? message,
  4. bool showCancel = true,
  5. String? cancelText,
  6. bool barrierDismissible = true,
})

List of actions in a bottom sheet with a Cancel row. UNavigator.actionSheet(actions: [UNavAction(label: "Edit", onTap: edit)])

Implementation

static Future<T?> actionSheet<T>({
  required List<UNavAction> actions,
  String? title,
  String? message,
  bool showCancel = true,
  String? cancelText,
  bool barrierDismissible = true,
}) => showModalBottomSheet<T>(
  context: navigatorKey.currentContext!,
  isDismissible: barrierDismissible,
  showDragHandle: true,
  builder: (BuildContext context) => SafeArea(
    child: UColumn(
      spacing: 8,
      mainAxisSize: MainAxisSize.min,
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: <Widget>[
        if (title != null) UTextTitleMedium(title, textAlign: TextAlign.center).pOnly(bottom: 4),
        if (message != null) UTextBodySmall(message, textAlign: TextAlign.center).pOnly(bottom: 8),
        ...actions.map(
          (UNavAction action) => ListTile(
            enabled: action.enabled,
            leading: action.icon != null ? Icon(action.icon, color: action.isDestructive ? Theme.of(context).colorScheme.error : null) : null,
            trailing: Icon(Icons.arrow_forward_ios, color: action.isDestructive ? Theme.of(context).colorScheme.error : null),
            title: UTextBodyLarge(action.label, color: action.isDestructive ? Theme.of(context).colorScheme.error : null),
            onTap: action.onTap,
          ),
        ),
        if (showCancel)
          ListTile(
            title: UTextBodyLarge(cancelText ?? U.s.cancel, textAlign: TextAlign.center),
            onTap: back,
          ),
      ],
    ),
  ),
);