altAppBarTheme static method
- BuildContext context
Alternative app bar theme that uses the primary color as the background of the app bar.
For styling app bars, it is better to use AltAppBarTheme directly, since this also applies themeing to other related components.
Implementation
static AppBarTheme altAppBarTheme(BuildContext context) {
final primaryBrightness =
ThemeData.estimateBrightnessForColor(context.colorScheme.primary);
return context.theme.appBarTheme.copyWith(
backgroundColor: context.colorScheme.primary,
foregroundColor: context.colorScheme.onPrimary,
iconTheme: IconThemeData(color: context.colorScheme.onPrimary),
titleTextStyle: context.textTheme.titleMedium?.copyWith(
color: context.colorScheme.onPrimary,
),
surfaceTintColor: context.colorScheme.primary,
systemOverlayStyle:
context.theme.appBarTheme.systemOverlayStyle?.copyWith(
statusBarBrightness: primaryBrightness,
statusBarColor: context.colorScheme.primary,
statusBarIconBrightness: primaryBrightness.inverse,
),
);
}