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

Issue

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

Solution

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),
  ],
)

Answered By – tanharpatel

Answer Checked By – Marie Seifert (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.