text static method

ComPopupMenu text({
  1. Key? key,
  2. required Widget child,
  3. required String text,
  4. TextStyle? textStyle,
  5. EdgeInsets? padding,
  6. Color? backgroundColor,
  7. BorderRadius? borderRadius,
  8. double? width,
  9. PressType pressType = PressType.singleClick,
  10. ComPopupMenuController? controller,
  11. PreferredPosition? position,
  12. bool showArrow = true,
  13. Color? arrowColor,
  14. void onMenuChanged(
    1. bool
    )?,
})

创建一个简单的文本菜单

便利构造函数,用于快速创建包含文本的弹出菜单

Implementation

static ComPopupMenu text({
  Key? key,
  required Widget child,
  required String text,
  TextStyle? textStyle,
  EdgeInsets? padding,
  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,
        padding: padding ??
            const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
        decoration: BoxDecoration(
          color: backgroundColor ??
              Theme.of(context).colorScheme.surfaceContainerLowest,
          borderRadius: borderRadius ??
              BorderRadius.circular(context.comTheme.shapes.mediumRadius),
        ),
        child: Text(
          text,
          style: textStyle,
        ),
      ),
    ),
    child: child,
  );
}