Skip to content

Instantly share code, notes, and snippets.

@MarcinusX
Created September 13, 2018 16:27
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/b9103fe68b5f8f95029bade06e196029 to your computer and use it in GitHub Desktop.
Save MarcinusX/b9103fe68b5f8f95029bade06e196029 to your computer and use it in GitHub Desktop.
class _HeightPickerState extends State<HeightPicker> {
double get _pixelsPerUnit {
return _drawingHeight / widget.totalUnits;
}
double get _sliderPosition {
double halfOfBottomLabel = labelsFontSize / 2;
int unitsFromBottom = widget.height - widget.minHeight;
return halfOfBottomLabel + unitsFromBottom * _pixelsPerUnit;
}
///returns actual height of slider to be able to slide
double get _drawingHeight {
double totalHeight = widget.widgetHeight;
double marginBottom = marginBottomAdapted(context);
double marginTop = marginTopAdapted(context);
return totalHeight - (marginBottom + marginTop + labelsFontSize);
}
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
_drawSlider(),
_drawLabels(),
],
);
}
Widget _drawSlider() {
return Positioned(
child: HeightSlider(height: widget.height),
left: 0.0,
right: 0.0,
bottom: _sliderPosition,
);
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment