
I'm currently struggling with adapting the background color.Ĭhild: Text(label, style: TextStyle(color: fontColor, fontWeight: boldLabel ? FontWeight.bold : FontWeight.normal)), Since FlatButtons are deprecated since I upgraded my flutter version. Is this the desired behavior? Maybe… But it is confusing since it is also not consistent with Material.I'm trying to migrate my FlatButton to TextButton. So that is why the FlatButton shows in blue (in this example I have not provided a primarySwatch, so the default one is Colors.blue for a Theme). But it will override the ButtonTextTheme to use the ButtonTextTheme.primary, while the default value is ButtonTextTheme.normal.
#Buttonbar flutter text color code
Fortunately, we can inspect all Flutter widgets since they are implemented in Dart.Ĭhecking the code of ButtonBar, we spot that indeed the ButtonBar wraps the buttons in a new ButtonTheme copied from the one from the ThemeData (either built internally or the one provided by us). This is giving us a clue about what is going on here. As we can read in the doc: The children are wrapped in a ButtonTheme that is a copy of the surrounding ButtonTheme with the button properties overridden by the properties of the ButtonBar as described above. Why FlatButton in a ButtonBar uses another color? Yeah. Let’s see what happens to wrap a RaisedButon and a FlatButton in the ButtonBar.

You can customize all InkWell, Icon or MaterialButton in the App defining attributes in the ThemeData. splashColor:Colors.pink, //we don't define the splashColor in ButtonThemeDaa

⚠️ Flat, Raised or OutlineButton define splashColor in ButtonThemeData.įor instance, observe the result if we have defined this ButtonThemeData in the Theming without providing a splashColor: theme: ThemeData( Check the method ButtonThemeData.getFillColor to know how it is filled. If no defined, the theme color primarySwatch is used (If theme is light, grey if it is dark). The color used for background color in RaisedButton.


If not provided, the primarySwatch is used (in some cases, see below). ThemeData.buttonColor: Default background color used by RaisedButtons.We can customize (coloring but no shape) Buttons using the following attributes in ThemeData. There are two classes that provide theming to buttons into our App.
