uppercase dart code example
Example 1: string to capital letter dart
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;
final helloWorld = 'hello world'.allInCaps;
final helloWorld = 'hello world'.capitalizeFirstofEach;
Example 2: dart char is uppercase
import 'dart:io';
main() {
print("Enter a string : ");
var str = stdin.readLineSync();
if (str[0].toUpperCase() == str[0]) {
print("The first character is uppercase");
} else {
print("The first character is not uppercase");
}
}