circle static method

Widget circle({
  1. Color mainColor = Colors.white,
  2. Color splashColor = Colors.grey,
  3. Color? shadowColor,
  4. Color disableColor = Colors.grey,
  5. Function? onClick,
  6. Function? onDoubleClick,
  7. Function? onLongClick,
  8. double? diameter,
  9. EdgeInsetsGeometry? padding,
  10. required Widget child,
  11. Offset shadowOffset = Offset.zero,
})

return custom button circle

Implementation

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

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

  /// [shadowColor] color for shadow button
  Color? shadowColor,

  /// [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,

  /// [diameter] diameter of circle button
  double? diameter,

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

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

  /// [shadowOffset] Position of shadow button. Default: Offset.zero
  Offset shadowOffset = Offset.zero,
}) {
  return Container(
    decoration: BoxDecoration(
      shape: BoxShape.circle,
      boxShadow: shadowColor == null
          ? []
          : [
              BoxShadow(
                blurRadius: 5,
                color: shadowColor,
                offset: shadowOffset,
              ),
            ],
    ),
    child: Material(
      borderRadius: BorderRadius.circular(diameter ?? 1000),
      color: onClick == null && onDoubleClick == null && onLongClick == null
          ? disableColor
          : mainColor,
      child: InkWell(
        borderRadius: BorderRadius.circular(diameter ?? 1000),
        splashColor: splashColor,
        onTap: onClick == null ? null : () => onClick(),
        onLongPress: onLongClick == null ? null : () => onLongClick(),
        onDoubleTap: onDoubleClick == null ? null : () => onDoubleClick(),
        child: padding == null
            ? Container(
                width: diameter,
                height: diameter,
                alignment: Alignment.center,
                child: child,
              )
            : Padding(
                padding: padding,
                child: child,
              ),
      ),
    ),
  );
}