The named parameter 'prefixIcon' isn't defined. Try correcting the name to an existing named parameter's name, or defining a named parameter with the name 'prefixIcon'.dartundefined_named_parameter No quick fixes available

 

This error appears because you are using the prefixIcon property, but the widget you are using doesn’t have that parameter.

Usually, prefixIcon is only available inside InputDecoration (for example in TextField or TextFormField), not directly on the widget.

Wrong example (causes the error):

TextField(
  prefixIcon: Icon(Icons.email), //  Error, because TextField doesn’t have this parameter
)

Correct example (use decorationInputDecoration):

TextField(
  decoration: InputDecoration(
    prefixIcon: Icon(Icons.email),
    labelText: 'Email',
    border: OutlineInputBorder(),
  ),
)

Or with TextFormField:

TextFormField(
  decoration: InputDecoration(
    prefixIcon: Icon(Icons.lock),
    labelText: 'Password',
    border: OutlineInputBorder(),
  ),
)

 So the solution is: move prefixIcon inside decoration: InputDecoration(...).


0 Comments:

Post a Comment