Question : dart capitalize first letter of each word
Answered by : lucas-pauw9cuw3gol
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'
Source : https://stackoverflow.com/questions/29628989/how-to-capitalize-the-first-letter-of-a-string-in-dart/29629114#29629114 | Last Update : Sun, 06 Sep 20
Question : Capitalize first letter in Flutter | Dart
Answered by : yawning-yacare-pzmnjuty0gj6
// 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 : https://stackoverflow.com/questions/29628989/how-to-capitalize-the-first-letter-of-a-string-in-dart | Last Update : Sat, 10 Sep 22