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

How to fix const Icon(Icons.person) Flutter error?

Hi I keep getting an error when trying to run main.dart due to the following error:

          Padding(
            padding: const EdgeInsets.only(bottom: 10),
            child: FormHelper.inputFieldWidget(
              context,
              const Icon(Icons.person), <---- This line over here 
              "Username",
              "Username",<---- This line over here 

I have found this answer: Flutter Dev, did you know how to fix this icon?

but I tried it from VS code and android studio.

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

Error received:

error: The argument type 'Icon' can't be assigned to the parameter type 'String'. (argument_type_not_assignable at [...] lib\screens\login_page.dart:115)

Question:

Why I am getting this error and how to avoid it?

>Solution :

You need to provide prefixIcon as one of the parameter, and add it after the two String.

 Padding(
            padding: const EdgeInsets.only(bottom: 10),
            child: FormHelper.inputFieldWidget(
              context,
              "Username",
              "Username",
              prefixIcon:Icon(Icons.person), <---- add prefixIcon here
             
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