Skip to content

Instantly share code, notes, and snippets.

@MarcinusX
Created September 13, 2018 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarcinusX/45236d93303d11405e3d97b4062014fe to your computer and use it in GitHub Desktop.
Save MarcinusX/45236d93303d11405e3d97b4062014fe to your computer and use it in GitHub Desktop.
...
@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