fix mask formatter in phone

This commit is contained in:
mso7nueh
2026-01-29 15:49:13 +03:00
parent 4ff880e079
commit 044d86e710
4 changed files with 27 additions and 5 deletions

View File

@@ -21,6 +21,7 @@ class FirstStepContent extends StatefulWidget {
class _FirstStepContentState extends State<FirstStepContent> {
final maskFormatterForBirthday = MaskTextInputFormatter(mask: '##.##.####', filter: {"#": RegExp(r'[0-9]')}, type: MaskAutoCompletionType.lazy);
final maskFormatter = MaskTextInputFormatter(mask: '+7 (###) ### ## ##', filter: {"#": RegExp(r'[0-9]')}, type: MaskAutoCompletionType.lazy);
final firstNameController = TextEditingController();
@@ -37,7 +38,10 @@ class _FirstStepContentState extends State<FirstStepContent> {
firstNameController.text = context.read<RegistrationCubitV2>().state.firstName;
lastNameController.text = context.read<RegistrationCubitV2>().state.lastName;
emailController.text = context.read<RegistrationCubitV2>().state.email;
phoneController.text = context.read<RegistrationCubitV2>().state.phone;
final phone = context.read<RegistrationCubitV2>().state.phone;
if (phone.isNotEmpty) {
phoneController.text = maskFormatter.maskText(phone);
}
dateController.text = context.read<RegistrationCubitV2>().state.birthday?.format('dd.MM.yyyy') ?? '';
}
@@ -113,6 +117,7 @@ class _FirstStepContentState extends State<FirstStepContent> {
hintText: '+7 (999) 999 99 99',
controller: phoneController,
hasError: !state.isPhoneValid,
inputFormatters: [maskFormatter],
keyboardType: TextInputType.phone,
onChanged: (val) {
context.read<RegistrationCubitV2>().setPhone(val);