buildButton method
Implementation
Widget buildButton(String title, {String? value, double offsetWidth = 0.0, double? customWidth}) {
GlobalKey anchorKey = GlobalKey();
if (isCaps) {
title = title.toUpperCase();
} else {
title = title.toLowerCase();
}
if (value == null) {
value = title;
}
return Container(
key: anchorKey,
decoration: BoxDecoration(borderRadius: BorderRadius.all(Radius.circular(5)), color: Colors.white),
child: Listener(
behavior: HitTestBehavior.translucent,
child: Container(
width: customWidth == null ? w - divide + offsetWidth : customWidth,
height: h - divide,
child: Text(title),
alignment: Alignment.center,
),
onPointerDown: (e) {
if (showKey) {
RenderBox renderBox = anchorKey.currentContext!.findRenderObject() as RenderBox;
var offset = renderBox.localToGlobal(Offset.zero);
setState(() {
currentChar = value;
left = offset.dx - w * 0.1;
top = offset.dy - h * 1.2 - (MediaQuery.of(anchorKey.currentContext!).size.height - getHeight(anchorKey.currentContext!));
});
}
controller!.addText(value!);
onChanged?.call(controller!.realText);
},
onPointerUp: (e) {
if (showKey) {
setState(() {
left = 0;
top = 0;
});
}
},
),
);
}