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

How do I align prefixIcon with text on textFormField?

I have the following code for my textFormField:

 Container(
                  alignment: Alignment.centerLeft,
                  height: media.height * 0.12,
                  decoration: txtFieldBoxDecoration,
                  child: TextFormField(
                    textAlignVertical: TextAlignVertical.center,
                    keyboardType: TextInputType.emailAddress,
                    style: const TextStyle(
                      color: Colors.white,
                      fontSize: 26,
                    ),
                    decoration: InputDecoration(
                      border: InputBorder.none,
                      contentPadding: const EdgeInsets.only(top: 14),
                      prefixIcon: const Icon(
                        Icons.email,
                        color: Colors.white,
                        size: 28,
                      ),
                      hintText: 'Insira seu E-mail',
                      hintStyle: GoogleFonts.openSans(
                          color: Colors.white54, fontSize: 26),
                    ),
                    onChanged: (value) {},
                  ),
                ),

And I’m getting the following result: enter image description here

How do I align the prefix Icon and the hintText like this: enter image description here

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 :

For align the prefix Icon and the hintText,
You have to remove below code from InputDecoration

contentPadding: const EdgeInsets.only(top: 14),

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