bool isFirstCharacterUpperCase(String str) {
if (str == null || str.isEmpty || str.trimLeft().isEmpty) {
return false;
}
String firstChar = str.trimLeft().substring(0, 1);
if (double.tryParse(firstChar) != null) {
return false;
}
return firstChar.toUpperCase() == str.substring(0, 1);
}
void main() {
var str = "Dart";
if (isFirstCharacterUpperCase(str)) {
print("The first character is uppercase");
} else {
print("The first character is not uppercase");
}
}
/*
run:
The first character is uppercase
*/