kmaterialButton function

Widget kmaterialButton(
  1. String text, {
  2. TextStyle? textStyle,
  3. int? height,
  4. int? minWidth,
  5. EdgeInsetsGeometry? margin,
  6. EdgeInsetsGeometry? padding,
  7. Color? background,
  8. ShapeBorder? shape,
  9. bool isDisabled = true,
  10. Color? disabledTextColor,
  11. Color? disabledColor,
  12. ShapeBorder? disableShape,
  13. bool clearElevation = false,
  14. VoidCallback? onClick,
})

MaterialButton text 文案 textStyle 文案样式 height 高度 minWidth 最小宽度 margin 外边距 padding 内边距 background 背景色 shape 形状 isDisabled 是否可点击 disabledTextColor 不可点击的文字颜色 disabledColor 不可点击的背景颜色 disableShape 不可点击的形状 clearElevation 去掉阴影 onClick 点击事件

Implementation

Widget kmaterialButton(
    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,
      ),
    ),
  );
}