Button color

705 views
Skip to first unread message

na...@alkon-tech.com

unread,
Jan 21, 2016, 3:18:05 PM1/21/16
to Flutter Dev
I need to change color of RaisedButton. I managed to change the color of the text, but not the background color of the button itself.
I tried to change color property, textTheme property. I tried to put Container inside the button and use BoxDecoration. Nothing worked. 


Does anybody know how to do it? Should be something very simple.

Thanks,

Nadia.

Adam Barth

unread,
Jan 21, 2016, 3:29:15 PM1/21/16
to na...@alkon-tech.com, Flutter Dev
Does the "color" argument of RaisedButton not do what you'd like?


Adam

na...@alkon-tech.com

unread,
Jan 21, 2016, 3:33:20 PM1/21/16
to Flutter Dev
No.

Adam Barth

unread,
Jan 21, 2016, 3:41:07 PM1/21/16
to na...@alkon-tech.com, Flutter Dev
I wonder if the trouble is that you haven't set an onPressed handler for the button.  Without an onPressed handler, the button will be disabled (and therefore gray).  Here's an example of a green button:

import 'package:flutter/material.dart';

class ButtonApp extends StatelessComponent {
  Widget build(BuildContext context) {
    return new Material(
      child: new Column(
        children: <Widget>[
          new RaisedButton(
            onPressed: () {
              print('first');
            },
            child: new Text("first")
          ),
          new RaisedButton(
            color: Colors.green[500],
            onPressed: () {
              print('second');
            },
            child: new Text("second")
          ),
        ],
        justifyContent: FlexJustifyContent.spaceAround
      )
    );
  }
}

void main() {
  runApp(new ButtonApp());
}

That should produce a green button on the bottom.

Adam

na...@alkon-tech.com

unread,
Jan 21, 2016, 4:48:41 PM1/21/16
to Flutter Dev
It worked. Thanks. But I wouldn't have though about it by myself. It's kinda counter intuitive. 
Also, your documentation is very scarce. Can you, please, add it as your action item to improve your docs?

Nadia.



On Thursday, January 21, 2016 at 12:18:05 PM UTC-8, na...@alkon-tech.com wrote:

Adam Barth

unread,
Jan 21, 2016, 4:51:33 PM1/21/16
to na...@alkon-tech.com, Flutter Dev
On Thu, Jan 21, 2016 at 1:48 PM <na...@alkon-tech.com> wrote:
It worked. Thanks. But I wouldn't have though about it by myself. It's kinda counter intuitive.

Yeah, other folks have run into the same issue.  We definitely need more documentation about this behavior.

Also, your documentation is very scarce. Can you, please, add it as your action item to improve your docs?

Yes, we definitely need to improve our docs.  I've filed a bug for this specific issue to make sure we address it:


Thanks,
Adam


On Thursday, January 21, 2016 at 12:18:05 PM UTC-8, na...@alkon-tech.com wrote:
I need to change color of RaisedButton. I managed to change the color of the text, but not the background color of the button itself.
I tried to change color property, textTheme property. I tried to put Container inside the button and use BoxDecoration. Nothing worked. 


Does anybody know how to do it? Should be something very simple.

Thanks,

Nadia.

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To post to this group, send email to flutt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/72d9c355-1450-4758-a7c6-2346a24d1f30%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

na...@alkon-tech.com

unread,
Jan 21, 2016, 4:53:29 PM1/21/16
to Flutter Dev
Great! Thanks!


On Thursday, January 21, 2016 at 12:18:05 PM UTC-8, na...@alkon-tech.com wrote:
Reply all
Reply to author
Forward
0 new messages