in controller class
late TextEditingController otpTextController;
@override
void onInit() {
otpTextController = TextEditingController();
super.onInit();
}
@override
void onClose() {
otpTextController.dispose();
super.onClose();
}
in View class
PinCodeTextField(
pinTheme: PinTheme(
shape: PinCodeFieldShape.box,
borderRadius: BorderRadius.circular(3),
fieldWidth: 65,
fieldHeight: 65,
borderWidth: .9,
inactiveColor: AppColors.appGreyColor,
activeColor: AppColors.appGreyColor,
selectedColor: AppColors.appGreyColor,
),
cursorColor: AppColors.appWhiteColor,
appContext: context,
controller: controller.otpTextController,
length: 4,
onChanged: (_) {},
keyboardType: TextInputType.number,
autoDisposeControllers: false,
hintCharacter: '-',
textStyle: Get.textTheme.headline1,
hintStyle: Get.textTheme.headline1!.copyWith(
color: AppColors.appWhiteColor,
fontWeight: FontWeight.bold,
),
errorTextSpace: 20,
validator: (value) {
if (GetUtils.isNumericOnly(value ?? '') &&
value?.length == 4) {
return null;
} else {
return AppErrors.invalidOtpDetails;
}
},
),
Comments
Post a Comment