flutter textformfield issue

Viewed 25
  if (isPraticeChecked)
                TextFormField(
                    decoration:
                        const InputDecoration(labelText: 'No.of Questions'),
                    controller: noOfquestionController,
                    keyboardType: TextInputType.number,
                    inputFormatters: [
                      FilteringTextInputFormatter.digitsOnly
                    ],
                    validator: (value) {
                      final isNum = num.tryParse(value!);
                      
                      if (isNum == null ||
                          int.parse(value) < 1 ||
                          int.parse(value) > 30) {
                        return 'No. of question must be 1 to 30.';
                      }
                      return null;

this is the textformfield keyboardtype.number this kb only receiving num if user enter other then num like "-",",",".," it is giving blank page

1 Answers

Looks like you are giving input from your laptop's or pc's keyboard. Don't do this and try it with emulator or your phone. When we choose input type as number, it only shows us a keyboard with numbers only in phone.

Related