validateTextShadows function
Validates and limits shadow list.
Implementation
List<Shadow>? validateTextShadows(
List<Shadow>? shadows, {
bool? enableSecurity,
}) {
final shouldValidate = enableSecurity ?? TextSecurityConfig.enforceValidation;
if (shadows == null || shadows.isEmpty) return shadows;
if (!shouldValidate) return shadows;
if (shadows.length > TextSecurityConfig.maxShadowCount) {
if (TextSecurityConfig.enableSecurityLogging) {
debugPrint(
'[SAC Text Security] Shadow count ${shadows.length} above max ${TextSecurityConfig.maxShadowCount}',
);
}
shadows = shadows.take(TextSecurityConfig.maxShadowCount).toList();
}
return shadows.map((shadow) {
double blurRadius = shadow.blurRadius;
if (blurRadius > TextSecurityConfig.maxShadowBlurRadius) {
if (TextSecurityConfig.enableSecurityLogging) {
debugPrint(
'[SAC Text Security] Shadow blur radius $blurRadius above max ${TextSecurityConfig.maxShadowBlurRadius}',
);
}
blurRadius = TextSecurityConfig.maxShadowBlurRadius;
}
return Shadow(
color: shadow.color,
offset: shadow.offset,
blurRadius: blurRadius,
);
}).toList();
}