RichThemeStateButton constructor

RichThemeStateButton({
  1. Key? key,
  2. double? width,
  3. double? height,
  4. EdgeInsetsGeometry? margin,
  5. EdgeInsetsGeometry? padding,
  6. required RichThemeStateBGType richBGColorType,
  7. bool needHighlight = false,
  8. double cornerRadius = 5.0,
  9. required String normalTitle,
  10. String? selectedTitle,
  11. TextStyle? titleStyle,
  12. ButtonImagePosition? imagePosition,
  13. Image? imageWidget,
  14. double imageTitleGap = 5,
  15. bool enable = true,
  16. bool selected = false,
  17. required void onPressed(),
})

Implementation

RichThemeStateButton({
  Key? key,
  double? width,
  double? height,
  EdgeInsetsGeometry? margin,
  EdgeInsetsGeometry? padding,
  required RichThemeStateBGType richBGColorType,
  bool needHighlight = false, // 是否需要高亮样式(默认false)
  double cornerRadius = 5.0,
  required String normalTitle,
  String? selectedTitle,
  TextStyle? titleStyle,
  ButtonImagePosition? imagePosition,
  Image? imageWidget, // 图片
  double imageTitleGap = 5, // 图片和文字之间的距离(imageWidget存在的时候才有效)
  bool enable = true,
  bool selected = false,
  required void Function() onPressed,
}) : super(
        key: key,
        width: width,
        height: height,
        margin: margin,
        padding: padding,
        childBuider: (bSelected) {
          String _currentTitle = normalTitle;
          if (selected) {
            _currentTitle = selectedTitle ?? normalTitle;
          }
          double? childWidth = width;
          double? childHeight = height;
          if (childWidth != null && childHeight != null) {
            if (bSelected) {
              childWidth -=
                  richStateTheme_selectedBorderWidth(richBGColorType) * 2;
              childHeight -=
                  richStateTheme_selectedBorderWidth(richBGColorType) * 2;
            } else {
              childWidth -=
                  richStateTheme_normalBorderWidth(richBGColorType) * 2;
              childHeight -=
                  richStateTheme_normalBorderWidth(richBGColorType) * 2;
            }
          }
          return ButtonChildWidget(
            width: childWidth,
            height: childHeight,
            title: _currentTitle,
            titleStyle: titleStyle,
            imagePosition: imagePosition,
            imageWidget: imageWidget,
            imageTitleGap: imageTitleGap,
          );
        },
        enable: enable,
        selected: selected,
        onPressed: () {
          onPressed();
        },
        cornerRadius: cornerRadius,
        normalBGColor: richStateTheme_normalBGColor(richBGColorType),
        normalTextColor: richStateTheme_normalTextColor(richBGColorType),
        normalBorderWidth: richStateTheme_normalBorderWidth(richBGColorType),
        normalBorderColor: richStateTheme_normalBorderColor(richBGColorType),
        normalBackgroundHighlightColor:
            richStateTheme_normalBackgroundHighlightColor(richBGColorType),
        selectedBGColor: richStateTheme_selectedBGColor(richBGColorType),
        selectedTextColor: richStateTheme_selectedTextColor(richBGColorType),
        selectedBorderWidth:
            richStateTheme_selectedBorderWidth(richBGColorType),
        selectedBorderColor:
            richStateTheme_selectedBorderColor(richBGColorType),
        selectedBackgroundHighlightColor:
            richStateTheme_selectedBackgroundHighlightColor(richBGColorType),
        highlightOpacity: needHighlight ? 0.7 : 1.0,
      );