How to restrict to number only keypad in Flutter.

To restrict only numeric input keyboard we have to provide a single line of code in our TextField. It’s a parameter by the name of keyboardType: and we enter an enum of TextInputType. The complete code is given below:-

   TextField(
    decoration: new InputDecoration(labelText: "This is a test TextField"),
    keyboardType: TextInputType.number,
            )

We will get a numeric keyboard like this one:-

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.