clamp method

TextScaler clamp({
  1. double minScaleFactor = 0,
  2. double maxScaleFactor = double.infinity,
})

Returns a new TextScaler that restricts the scaled font size to within the range [minScaleFactor * fontSize, maxScaleFactor * fontSize].

Implementation

TextScaler clamp({ double minScaleFactor = 0, double maxScaleFactor = double.infinity }) {
  assert(maxScaleFactor >= minScaleFactor);
  assert(!maxScaleFactor.isNaN);
  assert(minScaleFactor.isFinite);
  assert(minScaleFactor >= 0);

  return minScaleFactor == maxScaleFactor
    ? TextScaler.linear(minScaleFactor)
    : _ClampedTextScaler(this, minScaleFactor, maxScaleFactor);
}