Home > Software engineering >  Is it possible to create a text field phone number mask which is not disappearing when user inputs,
Is it possible to create a text field phone number mask which is not disappearing when user inputs,

Time:06-19

Is it possible to create phone number mask like this in flutter: preview

CodePudding user response:

you can use prefix widget or into onChange textField method like below code handle it:

final c = TextEditingController();
bool x = true;

TextFormField(
      controller: c,
      onChanged: (val) {
        if (x) {
          x = false;
          c.text = '99' val;
        } else if (val.length == 0) x = true;
      },
    )
  • Related