zhenglu

Optimize capitalize method

@@ -506,19 +506,8 @@ class GetUtils { @@ -506,19 +506,8 @@ class GetUtils {
506 /// Capitalize each word inside string 506 /// Capitalize each word inside string
507 /// Example: your name => Your Name, your name => Your name 507 /// Example: your name => Your Name, your name => Your name
508 static String capitalize(String value) { 508 static String capitalize(String value) {
509 - if (isNullOrBlank(value)) {  
510 - return null;  
511 - }  
512 -  
513 - final separatedWords = value.split(' ');  
514 - var result = '';  
515 -  
516 - for (var word in separatedWords) {  
517 - result += capitalizeFirst(word);  
518 - result += ' ';  
519 - }  
520 -  
521 - return result.trim(); 509 + if (isNullOrBlank(value)) return null;
  510 + return value.split(' ').map(capitalizeFirst).join(' ');
522 } 511 }
523 512
524 /// Uppercase first letter inside string and let the others lowercase 513 /// Uppercase first letter inside string and let the others lowercase