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

I want the value of textfield when user prints enter

I am a beginner in flutter, I was working with the textfield widget. I want the value of textfield when user click enter or when the value is completed. Thanks for the help in advance.

TextField(
              cursorColor: primaryColor,
              decoration: InputDecoration(
                icon: Icon(
                  Icons.search,
                  color: primaryColor,
                ),
                hintText: 'Search for your favourite',
                border: InputBorder.none,
              ),
                          ),

>Solution :

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

To get the text field value once it is completed, you can use the text field onSubmitted function. It provides you with the value once the user submits it. Here is the line of code you need to add.

TextField(
          cursorColor: primaryColor,
          decoration: InputDecoration(
            icon: Icon(
              Icons.search,
              color: primaryColor,
            ),
            hintText: 'Search for your favourite',
            border: InputBorder.none,
          ),
          onSubmitted: (value) {
            print(value);  // This will print the value submitted by the user. You can add your function inside this.
          },
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