Do not draw Slider tick marks if they are too dense (#27969)

This commit is contained in:
Anthony 2019-02-14 19:42:30 -05:00 committed by Hans Muller
parent d1707ab0ad
commit d1371cd269

View File

@ -1005,11 +1005,14 @@ class _RenderSlider extends RenderBox {
isEnabled: isInteractive,
sliderTheme: _sliderTheme,
).width;
// If the ticks would be too dense, don't bother painting them.
if ((trackRect.width - tickMarkWidth) / divisions >= 3.0 * tickMarkWidth) {
for (int i = 0; i <= divisions; i++) {
final double tickValue = i / divisions;
// The ticks are mapped to be within the track, so the tick mark width
// must be subtracted from the track width.
final double tickX = trackRect.left + tickValue * (trackRect.width - tickMarkWidth) + tickMarkWidth / 2;
final double tickX = trackRect.left +
tickValue * (trackRect.width - tickMarkWidth) + tickMarkWidth / 2;
final double tickY = trackRect.center.dy;
final Offset tickMarkOffset = Offset(tickX, tickY);
_sliderTheme.tickMarkShape.paint(
@ -1024,6 +1027,7 @@ class _RenderSlider extends RenderBox {
);
}
}
}
if (isInteractive && label != null && !_valueIndicatorAnimation.isDismissed) {
if (showValueIndicator) {