[FIXED] I want to change the color on Flutter but I'm stuck

Issue

Some code snippets:

child: TextButton(
                    color: Colors.black,
                    child: const Text(
                      'Dark',
                      style: TextStyle(color: Colors.white),
                    ),
                    onPressed: () {
                      setState(() {
                        darkMode = true;
                      });
                    },
                  ),

Error:

The named parameter 'color' isn't defined.
Try correcting the name to an existing named parameter's name, or defining a named parameter with the name 'color'.

How can I fix this error? Appreciate if someone can advise. Thank you in advance!

Solution

TextButton n’a pas color comme parametre il faut ajoute la propriete color seulement dans style.

child: TextButton(
child: const Text(
‘Dark’,
style: TextStyle(color: Colors.white),
),
onPressed: () {
setState(() {
darkMode = true;
});
},
),

Answered By – Ayoub Ennaoui

Answer Checked By – Willingham (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published