options static method

ComPopupMenu options({
  1. Key? key,
  2. required Widget child,
  3. required List<PopupMenuOption> options,
  4. Color? backgroundColor,
  5. BorderRadius? borderRadius,
  6. double? width,
  7. PressType pressType = PressType.singleClick,
  8. ComPopupMenuController? controller,
  9. PreferredPosition? position,
  10. bool showArrow = true,
  11. Color? arrowColor,
  12. void onMenuChanged(
    1. bool
    )?,
})

创建一个包含多个选项的菜单

便利构造函数,用于快速创建选项列表菜单

Implementation

static ComPopupMenu options({
  Key? key,
  required Widget child,
  required List<PopupMenuOption> options,
  Color? backgroundColor,
  BorderRadius? borderRadius,
  double? width,
  PressType pressType = PressType.singleClick,
  ComPopupMenuController? controller,
  PreferredPosition? position,
  bool showArrow = true,
  Color? arrowColor,
  void Function(bool)? onMenuChanged,
}) {
  return ComPopupMenu(
    key: key,
    pressType: pressType,
    controller: controller,
    position: position,
    showArrow: showArrow,
    arrowColor: arrowColor,
    menuOnChange: onMenuChanged,
    menuBuilder: Builder(
      builder: (context) => Container(
        width: width ?? 180,
        decoration: BoxDecoration(
          color: backgroundColor ??
              Theme.of(context).colorScheme.surfaceContainerLowest,
          borderRadius: borderRadius ??
              BorderRadius.circular(context.comTheme.shapes.mediumRadius),
        ),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children:
              options.map((option) => _buildOptionItem(option)).toList(),
        ),
      ),
    ),
    child: child,
  );
}