As we are having android:textAllCaps="true"
feature in Android's Textview, how can we give this same feature in Text() Widget of Flutter?
I know Text('Abc'.toUpperCase())
, is one way but I don't want to do it manually. Is there any property of Text() widget that converts it automatically or any widget that has similar property?
As we all know, Flutter is a framework created using the dart programming language. Dart has a method toUpperCase() that is used to capitalize the String text.
(EDITED) My solution is like this:
Text("apple".toUpperCase())
Returns: APPLE
Use following function for the First word as Caps
String getCapitalizeString({String str}) { if (str.length <= 1) { return str.toUpperCase(); } return '${str[0].toUpperCase()}${str.substring(1)}'; }
Use :
Text(this.getCapitalizeString(str: listObj[position]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With