xxxxxxxxxx
import 'package:flutter/services.dart';
new TextField(
decoration: new InputDecoration(labelText: "Enter any number"),
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.digitsOnly
], // Only numbers can be entered in this input field
),
xxxxxxxxxx
//number keyboard input
TextField(
keyboardType: TextInputType.number,
)
//Only numbers can be entered from 0-9 input
import 'package:flutter/services.dart';
TextField(
decoration: InputDecoration(labelText: "Enter number"),
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.digitsOnly
],
),
xxxxxxxxxx
// import below library (if not used in code, import below library first).
import 'package:flutter/services.dart';
TextFormField(
keyboardType: TextInputType.number,
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
),
// can be applied to (pub.dev package pin_code_fields: ^7.4.0)
PinCodeTextField(
length: 6,
obscureText: true,
animationType: AnimationType.fade,
keyboardType:TextInputType.number,
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
cursorColor:Colors.black,
pinTheme: PinTheme(
shape: PinCodeFieldShape.underline,
// borderRadius: BorderRadius.circular(5),
fieldHeight: 47,
fieldWidth: 47,
selectedColor:Color(0xFF12877F),
selectedFillColor: Color(0xFFF3FBFB),
activeColor: Color(0xFF12877F),
activeFillColor: Color(0xFFF3FBFB),
inactiveColor:Color(0xFF81C1BD),
inactiveFillColor:Color(0xFFF3FBFB),
errorBorderColor:Color(0xFFFF2121),
),
animationDuration: Duration(milliseconds: 300),
enableActiveFill: true,
errorAnimationController: errorController,
controller: otpController,
onCompleted: (v) {
print("Completed");
},
onChanged: (value) {
print(value);
},
beforeTextPaste: (text) {
print("Allowing to paste $text");
//if you return true then it will show the paste confirmation dialog. Otherwise if false, then nothing will happen.
//but you can show anything you want here, like your pop up saying wrong paste format or etc
return true;
}, appContext: context,
),