extension MyStringExtensions on String? { // Gestiamo anche il nullable per sicurezza String myFormat() { if (this == null || this!.trim().isEmpty) return ''; return this! .trim() .toLowerCase() .split(' ') .where((word) => word.isNotEmpty) // Evita problemi con doppi spazi .map((word) { if (word.contains('iphone') || word.contains('ipad')) { return word.replaceFirst('ip', 'iP'); } if (word.contains('imac')) { return word.replaceFirst('im', 'iM'); } return word[0].toUpperCase() + word.substring(1); }) .join(' '); } }