SOUGAT RIYADH
SOUGAT RIYADH

Reputation: 701

Letter Spacing in TextFieldForm in Flutter

How to add letter spacing in textfieldform widget just like in Text widget there is an option of letter spacing.

Upvotes: 20

Views: 21701

Answers (2)

Peter Haddad
Peter Haddad

Reputation: 80914

Use the TextStyle widget:

TextFormField(
  style : TextStyle(letterSpacing : 2.0),
  // The validator receives the text that the user has entered.
  validator: (value) {
    if (value.isEmpty) {
      return 'Please enter some text';
    }
    return null;
  },
),

Upvotes: 6

Sarvesh Bhatnagar
Sarvesh Bhatnagar

Reputation: 1122

If you want letter spacing in normal text, use style property as shown below:

TextFormField(
  style: TextStyle(
    letterSpacing: 2.0,
  ),
),

If you want letter spacing in label text, use labelstyle property in input decoration as shown below

TextFormField(
  decoration: InputDecoration(
    labelText: 'Test',
    labelStyle: TextStyle(
       letterSpacing: 2.0,
    ),
 ),
),

In the same way you can style hint text too using hint style property.

Upvotes: 31

Related Questions