I'm trying to make a Flutter widget to set a temperature, meant to look like a thermostat knob. I've extended CustomPainter to actually draw this on the screen and now I'm trying to set the grab functionality so the user can rotate it.
I can use a GestureDetector widget to get a callback when the user touches the screen, but I need to know where it is relative to the center of the knob. Unfortunately, the position provided by the GestureDetector is in absolute coordinates while the canvas works relative to the origin of the widget. Is there a way I can convert one of these coordinates to the other?
That means I need either:
1) A way to get the tap position relative to the CustomPainter widget
2) A way to get the absolute position of the CustomPainter widget
I am unable to find an API which can provide either of these. Does such an API exist?
Context: https://github.com/dgp1130/thermo/blob/master/lib/widgets/temp_picker.dart
The way it is currently, rotating the thermostat works, but the "center" of the touch is actually about halfway above the real center because of the height of the app bar.
Thanks