getPreferredSize method Null safety

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

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 usually comes from MediaQueryData.textScaleFactor.


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