ThemeBGButton constructor

ThemeBGButton({
  1. Key? key,
  2. double? width,
  3. double? height,
  4. ThemeBGType? bgColorType,
  5. Color? bgColor,
  6. Color? textColor,
  7. bool needHighlight = false,
  8. required String title,
  9. TextStyle? titleStyle,
  10. Image? imageWidget,
  11. double imageTitleGap = 5,
  12. double? cornerRadius,
  13. bool enable = true,
  14. VoidCallback? onPressed,
})

Implementation

ThemeBGButton({
  Key? key,
  double? width,
  double? height,
  ThemeBGType? bgColorType,
  Color? bgColor, // 不设置 bgColor 的时候要设置 bgColorType
  Color? textColor, // 不设置 textColor 的时候要设置 bgColorType
  bool needHighlight = false, // 是否需要高亮样式(默认false)
  required String title,
  TextStyle? titleStyle,
  Image? imageWidget, // 图片
  double imageTitleGap = 5, // 图片和文字之间的距离(imageWidget存在的时候才有效)
  double? cornerRadius,
  bool enable = true,
  VoidCallback? onPressed, // null时候会自动透传事件
})  : assert(bgColorType != null || bgColor != null),
      assert(bgColorType != null || textColor != null),
      super(
        key: key,
        width: width,
        height: height,
        childBuider: (bSelected) {
          return ButtonChildWidget(
            title: title,
            titleStyle: titleStyle,
            imageWidget: imageWidget,
            imageTitleGap: imageTitleGap,
          );
        },
        enable: enable,
        selected: false,
        onPressed: onPressed,
        cornerRadius: cornerRadius ?? 5.0,
        normalBGColor: bgColor != null ? bgColor : themeColor(bgColorType),
        normalTextColor:
            textColor != null ? textColor : themeOppositeColor(bgColorType),
        normalBorderWidth: 0.0,
        normalBorderColor:
            textColor != null ? textColor : themeOppositeColor(bgColorType),
        // normalHighlightColor: Colors.yellow,
        highlightOpacity: needHighlight ? 0.7 : 1.0,
      );