flutter capitalize first letter code example

Example 1: flutter capitalize first letter textfield

textCapitalization: TextCapitalization.sentences

Example 2: 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'

Example 3: flutter to capital letter

'alphabet'.toUpperCase(); // 'ALPHABET'
'ABC'.toUpperCase();      // 'ABC'

Tags:

Misc Example