How to capitalize the first letter in text widget?
Text("${_products[index]["product_name"]}",style: TextStyle(fontSize: 22.sp,),)
How to capitalize the first letter in text widget?
Text("${_products[index]["product_name"]}",style: TextStyle(fontSize: 22.sp,),)
A function for capitalization of first letter
String capitalizeOnlyFirstLater() {
if(this.trim().isEmpty) return "";
return "${this[0].toUpperCase()}${this.substring(1)}";
}
Then call the function in text
Text("${_products[index]["product_name"].capitalizeOnlyFirstLater()}",style: TextStyle(fontSize: 22.sp,),)
You can get the first letter and convert it to uppercase and concatenate the rest with it.
final String productName = _products[index]["product_name"];
final String productNameInSentenceCase = productName[0] + productName.substring(1);
Text(productNameInSentenceCase, style: TextStyle(fontSize: 22.sp,),)