Instantly share code, notes, and snippets.

Embed
What would you like to do?
...
@override
Widget build(BuildContext context) {
return GestureDetector(
behavior: HitTestBehavior.translucent,
onTapDown: _onTapDown,
child: Stack(
children: <Widget>[
_drawPersonImage(),
_drawSlider(),
_drawLabels(),
],
),
);
}
_onTapDown(TapDownDetails tapDownDetails) {
int height = _globalOffsetToHeight(tapDownDetails.globalPosition);
widget.onChange(_normalizeHeight(height));
}
int _normalizeHeight(int height) {
return math.max(widget.minHeight, math.min(widget.maxHeight, height));
}
int _globalOffsetToHeight(Offset globalOffset) {
RenderBox getBox = context.findRenderObject();
Offset localPosition = getBox.globalToLocal(globalOffset);
double dy = localPosition.dy;
dy = dy - marginTopAdapted(context) - labelsFontSize / 2;
int height = widget.maxHeight - (dy ~/ _pixelsPerUnit);
return height;
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment