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 ButtonThemeData is provided, values from ThemeData won’t be taken into account at all! I found some issues on theming the buttons when trying some Google CodeLabs or creating my Apps… And this is why: Particularities using ThemeData and ButtonThemeData ButtonThemeData.height: Default height.ButtonThemeData.minWidth: Default minimum width.ButtonThemeData.hoverColor: Same as ThemeData.ButtonThemeData.highlightColor: Same as ThemeData.ButtonThemeData.splashColor: Same as ThemeData used in FlatButton, OutlineButton or RaisedButton.ButtonThemeData.buttonColor: Same as ThemeData.See examples in section Theme Buttons Table ButtonThemeDataīut wait! if you define a ButtonThemeData, all properties above can be overridden by ButtonThemeData. ThemeData.hoverColor: Color when the mouse passes over it.ThemeData.highlightColor: Color used to fill the background when splash has ended.ThemeData.splashColor: Color to start filling the Buttons when pressed.? If you want to fill with color a FlatButton or OutlineButton then use parameter color when building the button. 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. Import 'package:font_awesome_flutter/font_awesome_flutter.There are two classes that provide theming to buttons into our App. Here is the entire dart file: import 'package:flutter/material.dart' Im trying to create a horizontal scrolling sub menu underneath the app bar and it was suggested I use a Tab bar. When I change the theme data colors the background color doesnt change. Primar圜olor: Colors.pink, //Changing this will change the color of the TabBar
I am trying to change the background color of the tab bar in flutter, I have tried the following ( which was accepted as an answer on this forum ) but it didnt work: