Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

dart capitalize first letter of each word

extension CapExtension on String {
  String get inCaps => '${this[0].toUpperCase()}${this.substring(1)}';
  String get allInCaps => this.toUpperCase();
  String get capitalizeFirstofEach => this.split(" ").map((str) => str.capitalize).join(" ");
}

final helloWorld = 'hello world'.inCaps; // 'Hello world'
final helloWorld = 'hello world'.allInCaps; // 'HELLO WORLD'
final helloWorld = 'hello world'.capitalizeFirstofEach; // 'Hello World'
Comment

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();
Comment

PREVIOUS NEXT
Code Example
Swift :: add shadow to collection view cell swift 
Swift :: tellraw minecraft 
Swift :: swift ui text align center 
Swift :: Split a String into an array in Swift 
Swift :: how to change the font of buttons programmatically swift 
Swift :: change from Date to String swift 5 
Swift :: Check if device is iPhone or not swift ios 
Swift :: swift set view z order front 
Swift :: swift for loop index 
Swift :: declaration of empty dictionary in swift language 
Swift :: swift function with return value 
Swift :: change selection color uitableviewcell swift 
Swift :: ShareSheet: UIViewControllerRepresentable swiftui 
Swift :: rtl ios swift 
Swift :: Save class in userdefaults ios swift 
Swift :: Swift Properties 
Swift :: using swipe gesture recognizer swift 
Swift :: deselect cell swift 
Swift :: clone repo using jenkins pipeline 
Swift :: swift string to dictionary 
Swift :: swift sort array 
Swift :: how to low case string swift 
Swift :: uilabel make bold 
Swift :: Prime number or not program in swift basic programs 
Swift :: Swift Calling a function in Swift 
Swift :: and or in swift 
Swift :: toggle button swift 
Swift :: Swift How to declare an optional in Swift? 
Swift :: bold world in text swift 
Swift :: free robux codes 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =