koahPredictedTextCapacity function

int? koahPredictedTextCapacity({
  1. required int widthDp,
  2. required int heightDp,
  3. String? fontFamily,
  4. TextScaler? textScaler,
})

The textLength.max budget the SDK would send for a card_text_md slot of widthDp x heightDp, quantized/capped exactly like the wire value, or null when no budget is sent (an axis is unbounded, or the slot is too small for a text budget). fontFamily/textScaler should match the slot's resolved KoahTheme font and device text scale.

Implementation

int? koahPredictedTextCapacity({
  required int widthDp,
  required int heightDp,
  String? fontFamily,
  TextScaler? textScaler,
}) {
  final scaler =
      textScaler ??
      TextScaler.linear(
        WidgetsBinding.instance.platformDispatcher.textScaleFactor,
      );
  final estimator = TextPainterCapacityEstimator(
    fontFamily: fontFamily,
    textScaler: scaler,
  );
  final props = KoahTextCapacity.textLengthProperties(
    KoahFormatContext(maxWidth: widthDp, maxHeight: heightDp),
    estimator,
  );
  final textLength = props?['textLength'] as Map<String, dynamic>?;
  return textLength?['max'] as int?;
}