bottomSheetTheme static method

BottomSheetThemeData bottomSheetTheme({
  1. Color? backgroundColor,
  2. Color? modalBackgroundColor,
  3. double? elevation,
  4. double? modalElevation,
  5. double? radius,
  6. Clip clipBehavior = Clip.antiAlias,
  7. BoxConstraints? constraints,
  8. Color? shadowColor,
  9. Color? surfaceTintColor,
})

An opinionated BottomSheetThemeData with custom top corner radius.

Corner radius defaults to kBottomSheetBorderRadius = 28, elevation to kBottomSheetElevation = 4 and modalElevation to kBottomSheetModalElevation = 8.

Implementation

static BottomSheetThemeData bottomSheetTheme({
  /// Default value for [BottomSheet.backgroundColor].
  ///
  /// If null, defaults to Flutter's default, which is theme canvas color in
  /// M2 mode and surfaceContainerLow in M3 mode.
  final Color? backgroundColor,

  /// Value for [BottomSheet.backgroundColor] when the Bottom sheet is
  /// presented as a modal bottom sheet.
  ///
  /// If null, defaults to Flutter's default, which is theme canvas color in
  /// M2 mode and surfaceContainerLow in M3 mode.
  final Color? modalBackgroundColor,

  /// The none modal bottom sheet elevation.
  ///
  /// If null, defaults to [kBottomSheetElevation] = 1.
  final double? elevation,

  /// The modal bottom sheet elevation.
  ///
  /// If null, defaults to [kBottomSheetModalElevation] = 2.
  final double? modalElevation,

  /// The corner radius of the top corners.
  ///
  /// If not defined, defaults to [kBottomSheetBorderRadius] 28p.
  ///
  /// Follows Material M3 guide as default value.
  /// https://m3.material.io/components/bottom-sheets/specs
  final double? radius,

  /// The clipBehavior of the bottom sheet theme, defaults to
  /// [Clip.antiAlias] for smoother clipping when using rounded corners.
  ///
  /// This property is not available in [FlexSubThemeData] but you can use
  /// it if you otherwise use this as theme helper.
  final Clip clipBehavior = Clip.antiAlias,

  /// Constrains the size of the [BottomSheet].
  ///
  /// If null, the bottom sheet's size will be unconstrained.
  final BoxConstraints? constraints,

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

  /// Overrides the default value for surfaceTintColor.
  ///
  /// See [Material.surfaceTintColor] for more details.
  final Color? surfaceTintColor,
}) =>
    BottomSheetThemeData(
      backgroundColor: backgroundColor,
      modalBackgroundColor: modalBackgroundColor,
      elevation: elevation ?? kBottomSheetElevation,
      modalElevation: modalElevation ?? kBottomSheetModalElevation,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.only(
          topLeft: Radius.circular(radius ?? kBottomSheetBorderRadius),
          topRight: Radius.circular(radius ?? kBottomSheetBorderRadius),
        ),
      ),
      clipBehavior: clipBehavior,
      constraints: constraints,
      shadowColor: shadowColor,
      surfaceTintColor: surfaceTintColor,
    );