Home > OS >  Uppercase in Textfield and add dash automatically after 5 characters
Uppercase in Textfield and add dash automatically after 5 characters

Time:03-31

Convert entered characters to uppercase since PIN can be alphanumeric and Format pin entry with a dash, after at least 5 characters have been entered.

Visibility(
          visible: _pinAttemptsRemaining > 0 && pin != duplicatedValue,
          child: ConstrainedBox(
            constraints: const BoxConstraints.tightFor(width: 450),
            child: TextField(
              maxLength: 10,
              keyboardType: TextInputType.text,

              onChanged: (text) {
                pin = text;
              },
              textAlign: TextAlign.left,
              // keyboardType: TextInputType.visiblePassword,
              decoration: InputDecoration(
                errorText: _errorText,
                icon: Icon(
                  Icons.dialpad,
                ),
                labelText: '8-digit PIN',
                contentPadding: EdgeInsets.symmetric(vertical: 10.0),
                focusedBorder: UnderlineInputBorder(
                  borderSide: BorderSide(color: Colors.transparent, width: 2),
                ),
                focusedErrorBorder: UnderlineInputBorder(
                  borderSide: BorderSide(color: Colors.red, width: 2),
                ),
                errorBorder: UnderlineInputBorder(
                  borderSide: BorderSide(color: Color(0xFFF696969), width: 1),
                ),
              ),
            ),
          ),
        ),

CodePudding user response:

To do Uppercase

Use TextCapitalization.characters: Capitalize all characters in the sentence.

TextField(
 textCapitalization: TextCapitalization.characters,
),

CodePudding user response:

To make a string, sentence, input all caps use this simple line:

TextField(

textCapitalization: TextCapitalization.characters, ),

This code will do it, if not comment on this awnser and I'll help you out! Howdee

  • Related