of static method
Returns the nearest TabTheme.
Implementation
static TabThemeData of(BuildContext context) {
final TabTheme? tabTheme =
context.dependOnInheritedWidgetOfExactType<TabTheme>();
TabThemeData? tabThemeData = tabTheme?.data;
if (tabThemeData == null || !tabThemeData._isConcrete) {
final ThemeData themeData = Theme.of(context);
final TextTheme textTheme = themeData.textTheme;
final ColorScheme colorScheme = themeData.colorScheme;
tabThemeData ??= themeData.tabTheme;
final tabValue =
_TabThemeData(textTheme: textTheme, colorScheme: colorScheme);
final EdgeInsets padding = tabThemeData.padding ?? tabValue.padding;
final double height = tabThemeData.height ?? tabValue.height;
final double width = tabThemeData.width ?? tabValue.width;
final Color tabBarBackgroundColor =
tabThemeData.tabBarBackgroundColor ?? tabValue.tabBarBackgroundColor;
final TextStyle textStyle = tabThemeData.textStyle ?? tabValue.textStyle;
final IconThemeData iconThemeData =
tabThemeData.iconThemeData ?? tabValue.iconThemeData;
final double itemSpacing =
tabThemeData.itemSpacing ?? tabValue.itemSpacing;
final EdgeInsets itemPadding =
tabThemeData.itemPadding ?? tabValue.itemPadding;
final Color itemColor = tabThemeData.itemColor ?? tabValue.itemColor;
final Color itemHoverColor =
tabThemeData.itemHoverColor ?? tabValue.itemHoverColor;
final Color itemHighlightColor =
tabThemeData.itemHighlightColor ?? tabValue.itemHighlightColor;
final bool itemFilled = tabThemeData.itemFilled ?? tabValue.itemFilled;
final Color itemBackgroundColor =
tabThemeData.itemBackgroundColor ?? tabValue.itemBackgroundColor;
final Color itemHoverBackgroundColor =
tabThemeData.itemHoverBackgroundColor ??
tabValue.itemHoverBackgroundColor;
final Color itemHighlightBackgroundColor =
tabThemeData.itemHighlightBackgroundColor ??
tabValue.itemHighlightBackgroundColor;
final Duration menuTransitionDuration =
tabThemeData.menuTransitionDuration ??
tabValue.menuTransitionDuration;
final Curve menuTrasitionCurve =
tabThemeData.menuTrasitionCurve ?? tabValue.menuTrasitionCurve;
final Curve menuTrasitionReverseCurve =
tabThemeData.menuTrasitionReverseCurve ??
tabValue.menuTrasitionReverseCurve;
return tabThemeData.copyWith(
padding: padding,
height: height,
width: width,
tabBarBackgroundColor: tabBarBackgroundColor,
textStyle: textStyle,
iconThemeData: iconThemeData,
itemSpacing: itemSpacing,
itemPadding: itemPadding,
itemColor: itemColor,
itemHoverColor: itemHoverColor,
itemHighlightColor: itemHighlightColor,
itemFilled: itemFilled,
itemBackgroundColor: itemBackgroundColor,
itemHoverBackgroundColor: itemHoverBackgroundColor,
itemHighlightBackgroundColor: itemHighlightBackgroundColor,
menuTransitionDuration: menuTransitionDuration,
menuTrasitionCurve: menuTrasitionCurve,
menuTrasitionReverseCurve: menuTrasitionReverseCurve,
);
}
assert(tabThemeData._isConcrete);
return tabThemeData;
}