validateDecorationThickness function
Validates decoration thickness within configured bounds.
Implementation
double validateDecorationThickness(
double? thickness, {
double defaultValue = 1.0,
bool? enableSecurity,
}) {
final shouldValidate = enableSecurity ?? TextSecurityConfig.enforceValidation;
if (thickness == null) return defaultValue;
if (!shouldValidate) return thickness;
if (thickness < 0) {
if (TextSecurityConfig.enableSecurityLogging) {
debugPrint(
'[SAC Text Security] Decoration thickness $thickness is negative, using 0',
);
}
return 0;
}
if (thickness > TextSecurityConfig.maxDecorationThickness) {
if (TextSecurityConfig.enableSecurityLogging) {
debugPrint(
'[SAC Text Security] Decoration thickness $thickness above max ${TextSecurityConfig.maxDecorationThickness}',
);
}
return TextSecurityConfig.maxDecorationThickness;
}
return thickness;
}