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

Showing a button to the user based on the data entered in the TextFormField

final TextEditingController _weight = TextEditingController();

 if (_weight.text.contains(RegExp(r'[0-9]')))
        Padding(
            padding: const EdgeInsets.only(bottom: 20),
            child: BMIButton(
              onpressed: () {
                Navigator.push(
                  context,
                  PageTransition(
                      type: PageTransitionType.rightToLeft,
                      child: BMIHeight(),
                      inheritTheme: true,
                      ctx: context),
                );
              },
            ))

I’m trying to show an OutlinedButton when the user enters some data into the textFormField. When I enter a value in the TextFormField and confirm, it doesn’t show a button, but when I hot reload it, it sees that value and shows the button.

>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

Try to add listener and call setState to update ui

 late final TextEditingController _weight = TextEditingController()
    ..addListener(() {
      setState(() {});
    });

And override the dispose method and depose this controller.

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