computeHeight static method

double computeHeight({
  1. required TextSpan text,
  2. MongolTextAlign textAlign = MongolTextAlign.top,
  3. @Deprecated('Use textScaler instead. ' 'Use of textScaleFactor was deprecated in preparation for the upcoming nonlinear text scaling support. ' 'This feature was deprecated after v3.12.0-2.0.pre.') double textScaleFactor = 1.0,
  4. TextScaler textScaler = TextScaler.noScaling,
  5. int? maxLines,
  6. String? ellipsis,
  7. TextHeightBasis textHeightBasis = TextHeightBasis.parent,
  8. double minHeight = 0.0,
  9. double maxHeight = double.infinity,
})

Computes the height of a configured MongolTextPainter.

This is a convenience method that creates a text painter with the supplied parameters, lays it out with the supplied minHeight and maxHeight, and returns its MongolTextPainter.height making sure to dispose the underlying resources. Doing this operation is expensive and should be avoided whenever it is possible to preserve the MongolTextPainter to paint the text or get other information about it.

Implementation

static double computeHeight({
  required TextSpan text,
  MongolTextAlign textAlign = MongolTextAlign.top,
  @Deprecated(
    'Use textScaler instead. '
    'Use of textScaleFactor was deprecated in preparation for the upcoming nonlinear text scaling support. '
    'This feature was deprecated after v3.12.0-2.0.pre.',
  )
  double textScaleFactor = 1.0,
  TextScaler textScaler = TextScaler.noScaling,
  int? maxLines,
  String? ellipsis,
  TextHeightBasis textHeightBasis = TextHeightBasis.parent,
  double minHeight = 0.0,
  double maxHeight = double.infinity,
}) {
  assert(
    textScaleFactor == 1.0 || identical(textScaler, TextScaler.noScaling),
    'Use textScaler instead.',
  );
  final MongolTextPainter painter = MongolTextPainter(
    text: text,
    textAlign: textAlign,
    textScaler: textScaler == TextScaler.noScaling
        ? TextScaler.linear(textScaleFactor)
        : textScaler,
    maxLines: maxLines,
    ellipsis: ellipsis,
    textHeightBasis: textHeightBasis,
  )..layout(minHeight: minHeight, maxHeight: maxHeight);

  try {
    return painter.height;
  } finally {
    painter.dispose();
  }
}