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:-
