border static method

Widget border({
  1. Color mainColor = Colors.white,
  2. required Color borderColor,
  3. double borderWidth = 2.0,
  4. Color splashColor = Colors.grey,
  5. Color disableColor = Colors.grey,
  6. Function? onClick,
  7. Function? onDoubleClick,
  8. Function? onLongClick,
  9. double? width,
  10. double? height,
  11. EdgeInsetsGeometry? padding,
  12. required Widget child,
  13. double radius = 4.0,
  14. Offset shadowOffset = Offset.zero,
})

return custom button which has border

Implementation

static Widget border({
  /// [mainColor] body color of button. Default: Colors.white
  Color mainColor = Colors.white,

  /// [borderColor] color of border
  required Color borderColor,

  /// [borderWidth] sized of border width. Default: 2.0
  double borderWidth = 2.0,

  /// [splashColor] color for splash effect. Default: Colors.grey
  Color splashColor = Colors.grey,

  /// [disableColor] color button if button disable / function onClick off. Default: Colors.grey
  Color disableColor = Colors.grey,

  /// [onClick] action when button clicked
  Function? onClick,

  /// [onDoubleClick] action when button double clicked
  Function? onDoubleClick,

  /// [onLongClick] action when button long press
  Function? onLongClick,

  /// [width] width of button
  double? width,

  /// [height] height of button
  double? height,

  /// [padding] padding of button
  EdgeInsetsGeometry? padding,

  /// [child] child of button. Widget can be anything as can as possible
  required Widget child,

  /// [radius] radius for angle button. Default: 4.0
  double radius = 4.0,

  /// [shadowOffset] Position of shadow button. Default: Offset.zero
  Offset shadowOffset = Offset.zero,
}) {
  return Material(
    borderRadius: BorderRadius.circular(radius),
    color: onClick == null && onDoubleClick == null && onLongClick == null
        ? disableColor
        : mainColor,
    child: InkWell(
      borderRadius: BorderRadius.circular(radius),
      splashColor: splashColor,
      onTap: onClick == null ? null : () => onClick(),
      onLongPress: onLongClick == null ? null : () => onLongClick(),
      onDoubleTap: onDoubleClick == null ? null : () => onDoubleClick(),
      child: Container(
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(radius),
          border: Border.all(color: borderColor, width: borderWidth),
        ),
        width: width,
        height: height,
        padding: width == null
            ? height == null
                ? EdgeInsets.symmetric(
                    horizontal: 16,
                    vertical: 8,
                  )
                : padding
            : height == null
                ? EdgeInsets.symmetric(
                    horizontal: 0,
                    vertical: 8,
                  )
                : padding ?? null,
        alignment: Alignment.center,
        child: child,
      ),
    ),
  );
}