Isac de Oliveira
Isac de Oliveira

Reputation: 1

I want to add a color in my TextButton and the error

When I add a color to my "TextButton" an error pop up.

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 do I solve it? Line of code below

Row(
    children: <Widget>[
        TextButton(
            onPressed: () {},  
            child: Text('Entrar'),
            color: Color(0xff7540ee).withOpacity(.2),
),

Upvotes: 0

Views: 586

Answers (4)

gazalala05
gazalala05

Reputation: 1

If you want to change TextButton color

Row(
    children: <Widget>[
         TextButton(
             ButtonStyle(backgroundColor: MaterialStateProperty.all(
                  Color(0xff7540ee).withOpacity(.2),
             ),
         ),
    ],
),

Upvotes: 0

Uncle Roger
Uncle Roger

Reputation: 183

Replace this code

child: Text('Entrar'), color: Color(0xff7540ee).withOpacity(.2),

to this

child: Text('Entrar', style: TextStyle(Color(0xff7540ee).withOpacity(.2)),

Upvotes: 2

Jungwon
Jungwon

Reputation: 1006

if you want change text color

Row(
      children: <Widget>[
        TextButton(
          onPressed: (){},
          child: Text('Entrar',
                      style: TextStyle(color: Colors.amber),
                     ),
        ),
      ]
    );

or.
if you want change button color

Row(
      children: <Widget>[
        Container(
          color: Colors.amber,
          child: TextButton(
          onPressed: (){},
          child: Text('Entrar',
                      style: TextStyle(color: Colors.amber),
                     ),
        ),
        ),
      ]
    );

Upvotes: 0

Meet Patel
Meet Patel

Reputation: 327

Paste this code it will work.

Row(
     children: <Widget>[
            TextButton(
              onPressed: () {},
              child: Text('Entrar'),
              style: ButtonStyle(
                foregroundColor: MaterialStateProperty.all(
                  Color(0xff7540ee).withOpacity(.2),
                ),
              ),
            ),
          ],
        ),

Upvotes: 0

Related Questions