Home > Mobile >  Flutter ${widget.name} into TextFormField
Flutter ${widget.name} into TextFormField

Time:09-18

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

CodePudding user response:

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)),
    ),
),
  • Related