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 ${widget.name} into TextFormField

is there any way to put ${widget.name} to hintText inside TextFormField?
It works fine with other Texts widgets, but inside hintText i’ve got an error

           Padding(
              padding: EdgeInsets.all(20.0),
              child: TextFormField(
                enabled: false,
                decoration: const InputDecoration(
                    border: UnderlineInputBorder(),
                    hintText: 'Name: ${widget.name}',
                    prefixIcon: Icon(Icons.done)),
              ),
            ),

error 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 :

The error in your screenshot says "Invalid constant value" in the last line. It should work if you remove the "const" from your InputDecoration.

Padding(
    padding: EdgeInsets.all(20.0),
    child: TextFormField(
    enabled: false,
    decoration: InputDecoration(
        border: UnderlineInputBorder(),
        hintText: 'Name: ${widget.name}',
        prefixIcon: Icon(Icons.done)),
    ),
),
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