elevation static method
Widget
elevation({
- Color mainColor = Colors.white,
- Color splashColor = Colors.grey,
- Color disableColor = Colors.grey,
- Color? shadowColor,
- Function? onClick,
- Function? onDoubleClick,
- Function? onLongClick,
- double? width,
- double? height,
- double? elevation,
- EdgeInsetsGeometry? padding,
- required Widget child,
- double radius = 4.0,
return custom button which has elevation
Implementation
static Widget elevation({
/// [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,
/// [shadowColor] color for shadow button
Color? shadowColor,
/// [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,
/// [elevation] elevation of button
double? elevation,
/// [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(
shadowColor: shadowColor,
elevation: elevation ?? 4,
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,
),
),
);
}