asButton function

Widget asButton(
  1. BuildContext context, {
  2. required Function onPressed,
  3. required Widget child,
  4. EdgeInsets? margin,
  5. EdgeInsets? padding,
  6. double? height,
  7. double? width,
  8. Alignment? alignment,
  9. Color? backgroundColor,
  10. BorderRadius? borderRadius,
  11. double? elevation,
})

Implementation

Widget asButton(
    BuildContext context, {
      required Function onPressed,
      required Widget child,
      EdgeInsets? margin,
      EdgeInsets? padding,
      double? height,
      double? width,
      Alignment? alignment,
      Color? backgroundColor,
      BorderRadius? borderRadius,
      double? elevation,
    }) {
  elevation ??= 0.5;
  return Container(
    height: height,
    width: width,
    margin: margin,
    padding: padding,
    alignment: alignment,
    child: ElevatedButton(
      onPressed: () {
        onPressed();
      },
      child: child,
      style: ButtonStyle(
          elevation: MaterialStateProperty.all(elevation),
          backgroundColor: MaterialStateProperty.all(
              backgroundColor ?? const Color.fromRGBO(212, 84, 11, 1.0)
      ),
          shape: MaterialStateProperty.all(RoundedRectangleBorder(
              borderRadius: borderRadius ?? BorderRadius.circular(8)))),
    ),
  );
}