I want to accept only numbers in textformfields. I have designed textformfield for accepting phone number. I have change keyboard type.
keyboardType: TextInputType.phone,
But, It can also accept special symbols or can paste other inputs also.
I want to accept only numbers in textformfields. I have designed textformfield for accepting phone number. I have change keyboard type.
keyboardType: TextInputType.phone,
But, It can also accept special symbols or can paste other inputs also.
Try below code, refer FilteringTextInputFormatter
import below library
import 'package:flutter/services.dart';
Your Widget:
TextFormField(
keyboardType: TextInputType.number,
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
//you can used below formater also
/* inputFormatters: [
FilteringTextInputFormatter.allow(
RegExp("[0-9]"),
),
],*/
),