Search code examples
androidiosflutterflutter-dependencies

Get a mask format from a flutter API


In my application I have an API that returns a mask, it can be CEP, CNPJ, CPF, whatever, the user that will choose. What I want is to see how I can put a mask to fit the mask placed in the API.

This is how my API data comes:

  {
        "id": 26934,
        "label": "Campo de Texto - Com Máscara",
        "required": true,
        "type": "T",
        "mascara": "99999-999",
        "formatacao": "S",
        "format": "S",
        "originalFormat": "S",
        "html5Input": false,
        "codcampodinamico": 26934,
        "fieldSize": "M",
        "value": null,
        "values": []
    },

here is my code:

but when I do it this way, when I go to type in my field, it doesn't let me type anything, I click on the key and it just adds the 99999-999


Solution

  • Good afternoon, I managed to solve it, as my API returned 9999 .. it did not understand the nines as a mask so I did this:

    mask: form.mask,
          
    filter: {"9": RegExp('')}
            
    type: MaskAutoCompletionType.lazy);