bottomAppBarTheme static method

BottomAppBarTheme bottomAppBarTheme({
  1. required ColorScheme colorScheme,
  2. SchemeColor? backgroundSchemeColor,
  3. double? elevation,
  4. NotchedShape? shape,
  5. double? height,
  6. EdgeInsetsGeometry? padding,
  7. Color? shadowColor,
  8. Color? surfaceTintColor,
  9. bool? useMaterial3,
})

An opinionated BottomAppBarTheme theme.

The BottomAppBarTheme allows setting only of background color in FCS. Other properties are not used by FCS at this stage.

The BottomAppBarTheme has no properties for foreground color. If you use a background color that requires different contrast color than the active theme's surface colors, you will need to set their colors on widget level.

Implementation

static BottomAppBarTheme bottomAppBarTheme({
  /// Typically the same [ColorScheme] that is also used for your [ThemeData].
  required final ColorScheme colorScheme,

  /// Selects which color from the passed in colorScheme to use as the
  /// background color for the [BottomAppBar].
  ///
  /// If not defined, [colorScheme.surface] will be used via default widget
  /// widget behavior for M3 mode and explicitly defined as used color in
  /// the created [BottomAppBarTheme] in M2 mode.
  final SchemeColor? backgroundSchemeColor,

  /// Overrides the default value for [BottomAppBar.elevation].
  ///
  /// If undefined (null), defaults to 3 in M3 and to 8 in M2 mode.
  final double? elevation,

  /// Overrides the default value for [BottomAppBar.shape].
  final NotchedShape? shape,

  /// Overrides the default value for [BottomAppBar.height].
  ///
  /// If this is null, then in M2 the default value is the minimum in relation
  /// to the content, in M3 defaults to 80.0.
  final double? height,

  /// Overrides the default value for [BottomAppBar.padding].
  ///
  /// In M3 the padding will default to
  /// `EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0)`
  /// In M2 the value will default to EdgeInsets.zero.
  final EdgeInsetsGeometry? padding,

  /// Overrides the default value of [BottomSheet.shadowColor].
  final Color? shadowColor,

  /// Overrides the default value for [BottomAppBar.surfaceTintColor].
  ///
  /// See [Material.surfaceTintColor] for more details.
  final Color? surfaceTintColor,

  /// A temporary flag used to opt-in to Material 3 features.
  ///
  /// If set to true, the theme will use Material3 default styles when
  /// properties are undefined, if false defaults will use FlexColorScheme's
  /// own opinionated default values.
  ///
  /// The M2/M3 defaults will only be used for properties that are not
  /// defined, if defined they keep their defined values.
  ///
  /// If undefined, defaults to false.
  final bool? useMaterial3,
}) {
  final bool useM3 = useMaterial3 ?? false;
  // Effective color, if null, keep null for M3 defaults via widget.
  final Color backgroundColor =
      schemeColor(backgroundSchemeColor ?? SchemeColor.surface, colorScheme);

  // TODO(rydmike): BottomAppBar color defaults to null only when using M3.
  // Due to Theme.Data.bottomAppBarColor being deprecated in Flutter SDK,
  // but still being used in default M2 for widget we have to create a
  // sub-theme with a background color in M2 when it is null, also the
  // dark mode default for M2 is horrific.
  final Color? effectiveColor =
      backgroundSchemeColor == null && useM3 ? null : backgroundColor;

  return BottomAppBarTheme(
    color: effectiveColor,
    elevation: elevation,
    height: height,
    padding: padding,
    shadowColor: shadowColor,
    surfaceTintColor: surfaceTintColor,
  );
}