Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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
                  ),
                ),
              ),
            ),
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading