showMenuDialog method

void showMenuDialog({
  1. String? title,
  2. required List<DialogMenuItem> menus,
})

Implementation

void showMenuDialog({
  String? title,
  required List<DialogMenuItem> menus,
}) {
  if (menus.isEmpty) {
    return;
  }
  List<Widget> ws = [];
  if (title.isNotEmptyOrNull) {
    ws.add(TextX.labelMedium(title!).padding(vertical: 15.h));
  }
  for (var element in menus) {
    ws.add(
      ListTile(
        leading: element.icon != null
            ? IconX.icon(
                element.icon,
                size: 16.sp,
              )
            : null,
        horizontalTitleGap: 5.w,
        title: TextX.bodyMedium(element.title),
        subtitle: element.subTitle != null ? TextX.bodySmall(element.subTitle!) : null,
      ).inkWell(
        onTap: () => element.onTap?.call(),
      ),
    );
  }
  Widget child = ws
      .toColumn(
        mainAxisSize: MainAxisSize.min,
        separator: const DividerX(),
      )
      .padding(bottom: 30.h)
      .scrollable()
      .constrained(
        maxHeight: 0.8.sh,
        minHeight: 0.2.sh,
      );

  showCupertinoModalBottomSheet(
    context: Get.context!,
    builder: (context) => child,
  );
}