Flutter, change the size of text entered by the user in the TextFormField

Advertisements

Helo boys and girls! I would like to change the size of the text that the user enters into the TextFormField field. This is the moment when the user clicks on the field and starts typing something. I read that I need to use FocusNode. I created such a feature, but my code doesn’t work. Only the size of the text before clicking on the field is changed. Below will show the code I created:

final FocusNode myFocusNode = FocusNode();

Container(
  child: TextFormField(
    focusNode: myFocusNode,
    autofocus: true,
    labelText: "Login",
    labelStyle: GoogleFonts.openSans(
      textStyle: TextStyle(
        fontSize: myFocusNode.hasFocus ? 20.0 : 20.0,
        color: Colors.black  
      ),  
    ),  
  ),
),

How to fix it?

>Solution :

Try this

Container(
              child: TextFormField(
                style: TextStyle(fontSize: 40), // <-- SEE HERE
                focusNode: myFocusNode,
                autofocus: true,
                labelText: "Login",
                labelStyle: GoogleFonts.openSans(
                  textStyle: TextStyle(
                      fontSize: myFocusNode.hasFocus ? 20.0 : 20.0,
                      color: Colors.black
                  ),
                ),
              ),
            ),

Leave a ReplyCancel reply