buttonElev method

Widget buttonElev(
  1. void onPressed(), {
  2. double? width,
  3. double? height,
  4. int? textSize,
  5. Color? textColor,
  6. Color? backgroundColor,
  7. double? radius,
  8. VoidCallback? onLongPress,
  9. bool removeShadow = false,
})

填充主题色, 按钮文字为白色 backgroundColor 背景填充色,没有则用主题色

Implementation

Widget buttonElev(void Function() onPressed,
    {double? width,
    double? height,
    int? textSize,
    Color? textColor,
    Color? backgroundColor,
    double? radius,
    VoidCallback? onLongPress,
    bool removeShadow = false}) {
  return SizedBox(
    width: width ?? double.infinity,
    height: height ?? 46.h,
    child: ElevatedButton(
      onPressed: onPressed,
      onLongPress: onLongPress,
      style: ButtonStyle(
        shadowColor: MaterialStateProperty.all(removeShadow ? Colors.transparent : Colors.black),
        padding: MaterialStateProperty.all<EdgeInsetsGeometry>(EdgeInsets.zero),
        backgroundColor: backgroundColor == null ? null : MaterialStateProperty.all(backgroundColor),
        shape: MaterialStateProperty.all(RoundedRectangleBorder(borderRadius: BorderRadius.circular(radius ?? 6.h))),
      ),
      child: Text(
        this,
        style: (textSize ?? 14).textStyle(textColor ?? Colors.white),
      ),
    ),
  );
}