I make a button with two side action, first reduce item count and second side increase item count, I need get coordinates of the pressed point of the button.
I used GestureDetector with onTapDown but it have a delay.
Thanks.
GestureDetector(
onTapDown: _handleTapDown
)
void _handleTapDown(TapDownDetails details) {
final RenderBox referenceBox = context.findRenderObject() as RenderBox;
setState(() {
final touchPoint = referenceBox.globalToLocal(details.globalPosition);
if (touchPoint.dx <= width of btn) {
print(touchPoint.dx);
} else {
print("-----${touchPoint.dx}");
}
});
}
current code
Container(
height: 30,
child: TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Design.appColor),
padding: MaterialStateProperty.all(EdgeInsets.symmetric(vertical: 8, horizontal: 10)),
shape: MaterialStateProperty.all(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
))
),
onPressed: (){
},
child: Container(
child: RichText(
text: TextSpan(
text: "",
children:[
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: Icon(Icons.remove, size: 14, color: Colors.white),
),
TextSpan(
text: " ${widget.model[index].sale?.minPrice ?? widget.model[index].sale?.price} ₽ ",
style: TextStyle(
color: Colors.white,
fontSize: 14,
fontWeight: FontWeight.w500,
fontFamily: "Inter"
),
),
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: Icon(Icons.add, size: 14, color: Colors.white),
)
],
),
),
),
),
);

