validateTabs<T> function

List<T> validateTabs<T>(
  1. List<T> tabs, {
  2. bool? enableSecurity,
})

Validate tabs list is within bounds. Pass enableSecurity to override global setting, or leave null to use global.

Implementation

List<T> validateTabs<T>(List<T> tabs, {bool? enableSecurity}) {
  if (tabs.isEmpty) {
    _logAppBarSecurity('Warning: Empty tabs list provided');
    return tabs;
  }

  final shouldValidate =
      enableSecurity ?? AppBarSecurityConfig.enforceValidation;
  if (!shouldValidate) return tabs;

  if (tabs.length > AppBarSecurityConfig.maxTabCount) {
    _logAppBarSecurity(
      'Tabs truncated from ${tabs.length} to ${AppBarSecurityConfig.maxTabCount}',
    );
    return tabs.take(AppBarSecurityConfig.maxTabCount).toList();
  }

  return tabs;
}