ThemeStateButton constructor
ThemeStateButton({
- Key? key,
- double? width,
- double? height,
- required ThemeStateBGType normalBGColorType,
- bool needHighlight = false,
- double cornerRadius = 5.0,
- required String normalTitle,
- String? selectedTitle,
- TextStyle? titleStyle,
- ButtonImagePosition? imagePosition,
- Image? imageWidget,
- double imageTitleGap = 5,
- bool enable = true,
- bool selected = false,
- required void onPressed(),
Implementation
ThemeStateButton({
Key? key,
double? width,
double? height,
required ThemeStateBGType normalBGColorType,
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,
childBuider: (bSelected) {
String _currentTitle = normalTitle;
if (selected) {
_currentTitle = selectedTitle ?? normalTitle;
}
return ButtonChildWidget(
title: _currentTitle,
titleStyle: titleStyle,
imagePosition: imagePosition,
imageWidget: imageWidget,
imageTitleGap: imageTitleGap,
);
},
enable: enable,
selected: selected,
onPressed: () {
onPressed();
},
cornerRadius: cornerRadius,
themeColor: stateThemeColor(normalBGColorType),
themeOppositeColor: stateThemeOppositeColor(normalBGColorType),
normalBorderWidth: 0.0,
selectedBorderWidth: 1.0,
// normalBackgroundHighlightColor: Colors.yellow,
// selectedBackgroundHighlightColor: Colors.pink,
highlightOpacity: needHighlight ? 0.7 : 1.0,
);