flutter-masked-text icon indicating copy to clipboard operation
flutter-masked-text copied to clipboard

optional character translator

Open deepak786 opened this issue 4 years ago • 0 comments

Currently, the library has the following translators.

return {
      'A': new RegExp(r'[A-Za-z]'),
      '0': new RegExp(r'[0-9]'),
      '@': new RegExp(r'[A-Za-z0-9]'),
      '*': new RegExp(r'.*')
};

It would be great to have a translator for optional things. like:

'a' = similar to 'A' but will be optional.
'1' = similar to '0' but will be optional.
'<' = similar to '@' but will be optional.
'>' = simlilar to '*' but will be optional.

For e.g:

if the mask is '11-1' then it can accept the following inputs:

9
9-9
99
99-9

I already tried to use the translator but it is not working:

_accountCtrl =
        MaskedTextController(mask: '**-*', translator: {
      '*': RegExp(r'([0-9]*)'),
    });

deepak786 avatar Jan 26 '21 16:01 deepak786