diff --git a/packages/flutter/lib/src/material/tabs.dart b/packages/flutter/lib/src/material/tabs.dart index 0256019bf9..096c045957 100644 --- a/packages/flutter/lib/src/material/tabs.dart +++ b/packages/flutter/lib/src/material/tabs.dart @@ -652,7 +652,9 @@ class TabBar extends Scrollable { TabBar({ Key key, this.labels, - this.isScrollable: false + this.isScrollable: false, + this.indicatorColor, + this.labelColor }) : super(key: key, scrollDirection: Axis.horizontal); /// The labels to display in the tabs. @@ -665,6 +667,15 @@ class TabBar extends Scrollable { /// share of the available space. final bool isScrollable; + /// The color of the line that appears below the selected tab. If this parameter + /// is null then the value of the Theme's indicatorColor property is used. + final Color indicatorColor; + + /// The color of selected tab labels. Unselected tab labels are rendered + /// with the same color rendered at 70% opacity. If this parameter is null then + /// the color of the theme's body2 text color is used. + final Color labelColor; + double get minimumHeight { for (TabLabel label in labels.values) { if (label.text != null && (label.icon != null || label.iconBuilder != null)) @@ -900,7 +911,7 @@ class _TabBarState extends ScrollableState> implements TabBarSelect ThemeData themeData = Theme.of(context); Color backgroundColor = Material.of(context).color; - Color indicatorColor = themeData.indicatorColor; + Color indicatorColor = config.indicatorColor ?? themeData.indicatorColor; if (indicatorColor == backgroundColor) { // ThemeData tries to avoid this by having indicatorColor avoid being the // primaryColor. However, it's possible that the tab bar is on a @@ -914,13 +925,14 @@ class _TabBarState extends ScrollableState> implements TabBarSelect final TextStyle textStyle = themeData.primaryTextTheme.body2; final IconThemeData iconTheme = themeData.primaryIconTheme; - final Color textColor = themeData.primaryTextTheme.body2.color.withAlpha(0xB2); // 70% alpha + final Color selectedLabelColor = config.labelColor ?? themeData.primaryTextTheme.body2.color; + final Color labelColor = selectedLabelColor.withAlpha(0xB2); // 70% alpha List tabs = []; bool textAndIcons = false; int tabIndex = 0; for (TabLabel label in config.labels.values) { - tabs.add(_toTab(label, tabIndex++, textColor, indicatorColor)); + tabs.add(_toTab(label, tabIndex++, labelColor, selectedLabelColor)); if (label.text != null && (label.icon != null || label.iconBuilder != null)) textAndIcons = true; }