validateLineHeight function

double validateLineHeight(
  1. double? height, {
  2. double defaultValue = 1.2,
  3. bool? enableSecurity,
})

Validates line height within configured bounds.

Implementation

double validateLineHeight(
  double? height, {
  double defaultValue = 1.2,
  bool? enableSecurity,
}) {
  final shouldValidate = enableSecurity ?? TextSecurityConfig.enforceValidation;

  if (height == null) return defaultValue;
  if (!shouldValidate) return height;

  if (height > TextSecurityConfig.maxLineHeight) {
    if (TextSecurityConfig.enableSecurityLogging) {
      debugPrint(
        '[SAC Text Security] Line height $height above max ${TextSecurityConfig.maxLineHeight}',
      );
    }
    return TextSecurityConfig.maxLineHeight;
  }

  if (height < TextSecurityConfig.minLineHeight) {
    if (TextSecurityConfig.enableSecurityLogging) {
      debugPrint(
        '[SAC Text Security] Line height $height below min ${TextSecurityConfig.minLineHeight}',
      );
    }
    return TextSecurityConfig.minLineHeight;
  }

  return height;
}