flat static method
flat return custom button which has flat
Implementation
static Widget flat({
/// [mainColor] body color of button. Default: Colors.white
Color mainColor = Colors.white,
/// [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,
}) {
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(
width: width,
height: height,
padding: width == null
? padding ??
EdgeInsets.symmetric(
horizontal: 16,
vertical: 8,
)
: height == null
? EdgeInsets.symmetric(
horizontal: 0,
vertical: 8,
)
: null,
alignment: Alignment.center,
child: child,
),
),
);
}