diff --git a/recipients_app/lib/view/widgets/welcome/otp_input.dart b/recipients_app/lib/view/widgets/welcome/otp_input.dart index 2c1633c01..d8413b032 100644 --- a/recipients_app/lib/view/widgets/welcome/otp_input.dart +++ b/recipients_app/lib/view/widgets/welcome/otp_input.dart @@ -27,6 +27,24 @@ class _OtpInputState extends State { digit4Controller = TextEditingController(); digit5Controller = TextEditingController(); digit6Controller = TextEditingController(); + + final controllers = [ + digit1Controller, + digit2Controller, + digit3Controller, + digit4Controller, + digit5Controller, + digit6Controller, + ]; + + digit1Controller.addListener(() { + final text = digit1Controller.text; + if (text.length > 1) { + for (int i = 0; i < text.length; i++) { + controllers[i].text = text[i]; + } + } + }); } @override @@ -54,6 +72,7 @@ class _OtpInputState extends State { } _checkCodeStatus(); }, + isFirstField: true, ), OtpInputField( controller: digit2Controller, diff --git a/recipients_app/lib/view/widgets/welcome/otp_input_field.dart b/recipients_app/lib/view/widgets/welcome/otp_input_field.dart index 372cf3d6c..95433649c 100644 --- a/recipients_app/lib/view/widgets/welcome/otp_input_field.dart +++ b/recipients_app/lib/view/widgets/welcome/otp_input_field.dart @@ -4,11 +4,13 @@ import "package:flutter/material.dart"; class OtpInputField extends StatelessWidget { final TextEditingController? controller; final Function(String?)? onChanged; + final bool isFirstField; const OtpInputField({ super.key, this.controller, this.onChanged, + this.isFirstField = false, }); @override @@ -43,7 +45,7 @@ class OtpInputField extends StatelessWidget { validator: null, textAlign: TextAlign.center, keyboardType: TextInputType.number, - maxLength: 1, + maxLength: isFirstField ? 6 : 1, ), ), ),