border static method
Widget
border({
- Color mainColor = Colors.white,
- required Color borderColor,
- double borderWidth = 2.0,
- Color splashColor = Colors.grey,
- Color disableColor = Colors.grey,
- Function? onClick,
- Function? onDoubleClick,
- Function? onLongClick,
- double? width,
- double? height,
- EdgeInsetsGeometry? padding,
- required Widget child,
- double radius = 4.0,
- 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,
),
),
);
}