Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Letter Spacing in TextFieldForm in Flutter

Tags:

flutter

dart

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

like image 608
SOUGAT RIYADH Avatar asked May 10 '20 11:05

SOUGAT RIYADH


People also ask

How do you right align text in flutter?

right aligns the text left and right inside its boundaries respectively. TextAlign. justify horizontally justifies the text over its container. textDirection: textDirection is used to specify the direction of the text inside a Text Widget say ltr (left-to-right) or rtl (right to left).


2 Answers

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.

like image 81
Sarvesh Bhatnagar Avatar answered Oct 02 '22 03:10

Sarvesh Bhatnagar


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;
  },
),
like image 35
Peter Haddad Avatar answered Oct 02 '22 01:10

Peter Haddad