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 to Align Flutter TextFormField HintText?

enter image description here

I want to center align HintText with "Ara…" by scrolling down a little bit. How can I do that?

Codes:

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

SizedBox(
  height: 45,
  child: TextFormField(
    decoration: const InputDecoration(
      prefixIconConstraints: BoxConstraints(
        minWidth: 65,
      ),
      isDense: true,
      prefixIcon: Icon(Icons.search, color: Color(0xFFD9D9D9), size: 30),
      hintText: "Ara...",
      hintStyle: TextStyle(color: Color.fromARGB(255, 184, 184, 184), fontSize: 19, fontFamily: "Inter Regular", fontWeight: FontWeight.bold),
      fillColor: Color.fromARGB(255, 64, 64, 73),
      filled: true,
      enabledBorder: OutlineInputBorder(
        borderRadius: BorderRadius.all(Radius.circular(15)),
        borderSide: BorderSide(color: Colors.transparent),
      ),
      focusedBorder: OutlineInputBorder(
        borderRadius: BorderRadius.all(Radius.circular(15)),
        borderSide: BorderSide(color: Colors.transparent),
      ),
    ),
    style: const TextStyle(fontFamily: "Inter Regular", fontSize: 19, color: Color.fromARGB(255, 167, 167, 167)),
  ),
),

Thanks for help.

>Solution :

Use contentPadding

SizedBox(
                        height: 45,
                        child: TextFormField(
                          decoration: const InputDecoration(
                            prefixIconConstraints: BoxConstraints(
                              minWidth: 65,
                            ),
                            isDense: true,
                            prefixIcon: Icon(Icons.search,
                                color: Color(0xFFD9D9D9), size: 30),
                            hintText: "Ara...",
                            contentPadding: EdgeInsets.symmetric(vertical: 12),
                            hintStyle: TextStyle(
                                color: Color.fromARGB(255, 184, 184, 184),
                                fontSize: 19,
                                fontFamily: "Inter Regular",
                                fontWeight: FontWeight.bold),
                            fillColor: Color.fromARGB(255, 64, 64, 73),
                            filled: true,
                            enabledBorder: OutlineInputBorder(
                              borderRadius: BorderRadius.all(Radius.circular(15)),
                              borderSide: BorderSide(color: Colors.transparent),
                            ),
                            focusedBorder: OutlineInputBorder(
                              borderRadius: BorderRadius.all(Radius.circular(15)),
                              borderSide: BorderSide(color: Colors.transparent),
                            ),
                          ),
                          style: const TextStyle(
                              fontFamily: "Inter Regular",
                              fontSize: 19,
                              color: Color.fromARGB(255, 167, 167, 167)),
                        ),
                      ),
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