kbutton function
Widget
kbutton(
- String text, {
- TextStyle? textStyle,
- int? height,
- int? minWidth,
- EdgeInsetsGeometry? margin,
- EdgeInsetsGeometry? padding,
- Color? background,
- ShapeBorder? shape,
- bool isDisabled = true,
- Color? disabledTextColor,
- Color? disabledColor,
- ShapeBorder? disableShape,
- bool clearElevation = false,
- VoidCallback? onClick,
MaterialButton
text 文案
textStyle 文案样式
height 高度
minWidth 最小宽度
margin 外边距
padding 内边距
background 背景色
shape 形状
isDisabled 是否可点击
disabledTextColor 不可点击的文字颜色
disabledColor 不可点击的背景颜色
disableShape 不可点击的形状
clearElevation 去掉阴影
onClick 点击事件
Implementation
Widget kbutton(
String text, {
TextStyle? textStyle,
int? height,
int? minWidth,
EdgeInsetsGeometry? margin,
EdgeInsetsGeometry? padding,
Color? background,
ShapeBorder? shape,
bool isDisabled = true,
Color? disabledTextColor,
Color? disabledColor,
ShapeBorder? disableShape,
bool clearElevation = false,
VoidCallback? onClick,
}) {
return Container(
margin: margin,
child: MaterialButton(
padding: padding,
color: background,
disabledTextColor: disabledTextColor,
disabledColor: disabledColor,
shape: isDisabled ? shape : (disableShape ?? shape),
height: height?.h,
minWidth: minWidth?.w,
onPressed: isDisabled ? onClick : null,
highlightElevation: clearElevation ? 0 : null,
elevation: clearElevation ? 0 : null,
disabledElevation: clearElevation ? 0 : null,
child: Text(
text,
style: textStyle,
),
),
);
}