backSpace method

Widget backSpace()

Implementation

Widget backSpace() {
  return ClipRRect(
    borderRadius: widget.borderRadius ?? BorderRadius.circular(0),
    child: Container(
      height: widget.height ?? height,
      width: (widget.width ?? width)! + 20,
      child: Material(
        type: MaterialType.button,
        color: widget.color,
        child: InkWell(
          highlightColor: widget.highlightColor,
          splashColor: widget.splashColor,
          onTap: () {
            HapticFeedback.heavyImpact();
            if (widget.controller!.text.isNotEmpty) {
              widget.controller?.text = widget.controller!.text
                  .substring(0, widget.controller!.text.length - 1);
              widget.controller?.selection = TextSelection.fromPosition(
                  TextPosition(offset: widget.controller!.text.length));
            }
          },
          onLongPress: () {
            if (widget.controller!.text.isNotEmpty) {
              widget.controller?.text = '';
              widget.controller?.selection = TextSelection.fromPosition(
                  TextPosition(offset: widget.controller!.text.length));
            }
          },
          child: Center(
            child: Icon(
              Icons.backspace,
              size: widget.letterStyle.fontSize,
              color: widget.letterStyle.color,
            ),
          ),
        ),
      ),
    ),
  );
}