how to display no. of character user can type and how many characters user had typed in TextFormField Flutter

113

You can add maxLength property (it will show the writtenCharacters/totalLimit)

TextFormField(
  maxLength: 45,
)

Or you can also have alternative (it will not show the writtenCharacters/totalLimit), but for this you need to import

import 'package:flutter/services.dart';

TextFormField(
  inputFormatters: [
    LengthLimitingTextInputFormatter(45),
  ],
)
Share:
113
Dhanraj Nimbalkar
Author by

Dhanraj Nimbalkar

Updated on December 12, 2022

Comments

  • Dhanraj Nimbalkar
    Dhanraj Nimbalkar over 1 year

    How can we display the count of input characters entered by the user and how many characters user can type in that TEXTFORMFIELD in Flutter? Like this enter image description here

    image credits : blog link

  • Dhanraj Nimbalkar
    Dhanraj Nimbalkar about 3 years
    But I need to use TEXTFORMFIELD not TEXTFIELD
  • Dhanraj Nimbalkar
    Dhanraj Nimbalkar about 3 years
    Thanks , Already I am using it(the 2nd one); but I want to display it as well.. Update :: Thanks the 1st one works. my bad
  • Tanha Patel
    Tanha Patel about 3 years
    Then 1st one can help!