How can I configure auto-capitalization behavior in Flutter's text entry fields?
Flutter has a textCapitalization property for textfields. Set this property to TextCapitalization.sentences or any of the available values eg .characters or .words Like so:
TextField(
keyboardType: TextInputType.text,
**textCapitalization: TextCapitalization.sentences,**
style: TextStyle(
fontSize: 30.0,
color: Colors.black,
fontWeight: FontWeight.bold
),
)
Here is the complete list of behaviors of TextInputAction
class
textCapitalization: TextField provides options for capitalizing the text entered by the user.
TextCapitalization.sentences
: This is the most common type of capitalization, and the first letter of each sentence is converted to uppercase.TextField( textCapitalization: TextCapitalization.sentences, ),
TextCapitalization.characters
: Capitalize all characters in the sentence.TextField( textCapitalization: TextCapitalization.characters, ),
TextCapitalization.words
: Capitalize the first letter of each word.TextField( textCapitalization: TextCapitalization.words, ),
Enable or disable autocorrection for a specific TextField. Use the AutoCorrect field to set it up. This also disables input suggestions.
TextField( autocorrect: false, ),
Note: Only supports text keyboards, other keyboard types will ignore this configuration. Capitalization is locale-aware.
The starting-lowercase was a bug in our iOS implementation of Flutter's keyboard wrapper, which has since been fixed as of today!
I filed a bug for making this configurable (so you can disable the autocapitalize sentences behavior) here: https://github.com/flutter/flutter/issues/9363
Please don't hesitate to reach out if this does not resolve your issue.