How to create number input field in flutter

This quick Fix Will Get you How to create a number input field in Flutter. Using TextField And TextFrormField Widget

This is super simple just need to add Some properties in the widgets and it will open up only the numbers Keyboard

How to create number input field

First, in the TextField you just need to add the property keyboardType

keyboardType: TextInputType.number

If you want to Strict The user to only type Numbers only then use inputFormatters: property

TextField(
  inputFormatters: [
     inputFormatters: [FilteringTextInputFormatter.digitsOnly],
  ],
)

For using this FilteringTextInputFormatter you need to import services.dart file

import 'package:flutter/services.dart';

To use this method in TextFormField all the code/ properties will remain the same

        TextFormField(
            keyboardType: TextInputType.number,
            inputFormatters: [FilteringTextInputFormatter.digitsOnly],
          )

Here is How to create a number input field in Flutter. For more QuickTips make Sure To read more.


For more Flutter tutorials, Tips, Tricks, Free code, Questions, and Error Solving.

Remember FlutterDecode.com

Leave a Comment