Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to change RaisedButton color

Tags:

flutter

dart

RaisedButton(
          onPressed: null,
          child: Text('Get in'), // change it to sign-in
          color: Colors.blue,
        )

I am creating this widget under children, but the color is not getting changed from its default grey color. I tried with hex code value but still no help.

like image 710
Biswajit Paul Avatar asked Dec 09 '18 18:12

Biswajit Paul


People also ask

How do I change the color of my Raisedbutton Flutter?

The Raised Button in flutter by default comes with a Argument or Prop named as color. The color argument is used to Set Change Raised Button Background Color in Flutter iOS Android mobile app. Color can support all the useful formats like Hex color code, ARGB, RGBA and also color constants.

How do you change the color of a raised button?

Go to your main. Inside the MaterialApp, find the ThemeData widget. Add the elevatedButtonTheme property inside and assign the ElevatedButtonThemeData(). Add the style property and change the color as you would change it for normal ElevatedButton. Place the ElevatedButton widget anywhere in your Flutter app and see.

How do you customize an ElevatedButton in Flutter?

Elevated Buttons cannot be styled i.e. you cannot modify the color of the button, font size, text style, etc explicitly like raised buttons. This class was launched in version 1.22 of flutter. You can pass text or icons as a child to them.

How do you change the material button background color in Flutter?

to Change Background color of Elevated Button in Flutter Elevated Button has a style Property And style property need ButtonStyle(). ButtonStyle has backgroundColor property which requires MaterialStateProperty. You can simply assign background color by MaterialStateProperty. all<Color>(Colors.


2 Answers

From RaisedButton documentation:

If the [onPressed] callback is null, then the button will be disabled and by default will resemble a flat button in the [disabledColor]. If you are trying to change the button's [color] and it is not having any effect, check that you are passing a non-null [onPressed] handler.

like image 121
jprogramista Avatar answered Sep 28 '22 13:09

jprogramista


RaisedButton color depends on is it onPress able or not like this one. You should add onPressed into the attribute

                           RaisedButton(
                              onPressed: () => {},
                              color: Colors.green,
                              child: Text(
                                'Login',
                                style: TextStyle(color: Colors.white),
                              ),
                            ),
like image 23
pavel Avatar answered Sep 28 '22 13:09

pavel