build method

  1. @override
dynamic build(
  1. dynamic context
)

Implementation

@override
Widget build(BuildContext context) {
  final color = this.color ?? context.colors.primary;
  final disabledColor = this.disabledColor ?? context.colors.disabledColor;
  final highlightColor = this.highlightColor ?? context.colors.secondary;
  final splashColor = this.splashColor ?? context.colors.surface;

  var isPressed = useState(false);
  final widget = getWidget(child, context);

  return ButtonBox(
    color: getColor(isPressed.value, color, disabledColor, highlightColor),
    disabledColor: disabledColor,
    highlightColor: highlightColor,
    splashColor: splashColor,
    border: border,
    borderRadius: borderRadius,
    elevation: elevation,
    child: isEnabled
        ? InkWell(
            borderRadius: borderRadius.resolve(TextDirection.ltr),
            onTap: () {
              isPressed.value
                  ? isPressed.value = false
                  : isPressed.value = true;
              onPressed();
            },
            splashColor: splashColor,
            child: widget,
          )
        : widget,
  );
}