Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

Capitalize first letter in Flutter | Dart

// string_extension.dart
extension StringExtension on String {
    String capitalize() {
      return "${this[0].toUpperCase()}${this.substring(1).toLowerCase()}";
    }
}

// in the file you want to use the extension 
import "string_extension.dart";

var someCapitalizedString = "someString".capitalize();
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Capitalize #letter #Flutter #Dart
ADD COMMENT
Topic
Name
4+7 =