Instantly share code, notes, and snippets.

Embed
What would you like to do?
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