Home > Mobile >  MaskedInputFormatter wont let me input numbers
MaskedInputFormatter wont let me input numbers

Time:08-16

I am using a mask for Austrailia 61 (###) ###-####. I need the number to be formatted to 61 (123) 456-7890. The solution works with PhoneInputFormatter. However, PhoneInputFormatter does not allow for formatting like () and -.

TextFormField(
  keyboardType: TextInputType.phone,
  autocorrect: false,
  inputFormatters: [
    MaskedInputFormater(' 61 (000) 000-0000')
  ],
  // .. etc
);

The above mask will not allow to enter either 1 or 6. How can I fix the issue to both keep the formatting and let user type the digits as well?

CodePudding user response:

There are some typo issue, try this for mask_text_input_formatter

MaskTextInputFormatter(mask: ' 61 (000) 000-0000')

CodePudding user response:

A quick glance at https://pub.dev/packages/flutter_multi_formatter seems to indicate that PhoneInputFormatter does allow for formatting with () and -.

Can you confirm that this is not the case?

PhoneInputFormatter.replacePhoneMask(
    countryCode: 'RU',
    newMask: ' 0 (000) 000 00 00',
);
PhoneInputFormatter.addAlternativePhoneMasks(
    countryCode: 'BR',
    alternativeMasks: [
    ' 00 (00) 0000-0000',
    ' (00) 00000',
    ' 00 (00) 00-0000',
    ],
);
  • Related