getPreferredSize method

  1. @override
Size getPreferredSize(
  1. bool isEnabled,
  2. bool isDiscrete, {
  3. required TextPainter labelPainter,
  4. required double textScaleFactor,
})
override

Returns the preferred size of the shape, based on the given conditions.

The isEnabled argument is false when RangeSlider.onChanged is null and true otherwise. When true, the slider will respond to input.

The isDiscrete argument is true if RangeSlider.divisions is non-null. When true, the slider will render tick marks on top of the track.

The labelPainter argument helps determine the width of the shape. It is variable width because it is derived from a formatted string.

The textScaleFactor argument can be used to determine whether the component should paint larger or smaller, depending on whether textScaleFactor is greater than 1 for larger, and between 0 and 1 for smaller. It's usually computed from MediaQueryData.textScaler.

Implementation

@override
Size getPreferredSize(
  bool isEnabled,
  bool isDiscrete, {
  required TextPainter labelPainter,
  required double textScaleFactor,
}) {
  assert(textScaleFactor >= 0);
  return _pathPainter.getPreferredSize(labelPainter, textScaleFactor);
}