cardTheme static method

CardTheme cardTheme({
  1. double? radius,
  2. double? elevation,
  3. Color? shadowColor,
  4. Color? surfaceTintColor,
  5. Clip clipBehavior = Clip.antiAlias,
})

An opinionated CardTheme with custom corner radius and elevation.

Corner radius defaults to kCardRadius = 12 and elevation defaults to kCardElevation = 0.

The corner radius 12 is the new default on Cards in M3 specification.

Implementation

static CardTheme cardTheme({
  /// Corner radius
  ///
  /// If not defined, defaults to [kCardRadius] 12dp,
  /// based on M3 Specification
  /// https://m3.material.io/components/cards/specs
  final double? radius,

  /// Card elevation.
  ///
  /// If not defined, defaults to 1 via M2 and M3 defaults.
  final double? elevation,

  /// Overrides the default value for [Card.shadowColor].
  ///
  /// If null, [Card] defaults to fully opaque black.
  final Color? shadowColor,

  /// Overrides the default value for [Card.surfaceTintColor].
  ///
  /// If null, [Card] will not display an overlay color.
  ///
  /// See [Material.surfaceTintColor] for more details.
  final Color? surfaceTintColor,

  /// The clipBehavior of the card theme, defaults to
  /// [Clip.antiAlias] for smooth clipping when using rounded corners.
  ///
  /// There is no config property in [FlexSubThemesData] for [clipBehavior],
  /// if needed it can be exposed. Feel free to make a PR or submit an issue.
  final Clip clipBehavior = Clip.antiAlias,
}) =>
    CardTheme(
      clipBehavior: clipBehavior,
      elevation: elevation,
      shadowColor: shadowColor,
      surfaceTintColor: surfaceTintColor,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.all(
          Radius.circular(radius ?? kCardRadius),
        ),
      ),
    );