getBoxWithElevation method

Widget getBoxWithElevation({
  1. required Widget child,
  2. double elevation = 4,
  3. double? padding,
  4. double? borderRadius,
  5. double verticalMargin = 8.0,
  6. Color color = Colors.white,
})

Creates an elevated card container with customizable styling.

This widget wraps content in a Material Card with configurable elevation, padding, border radius, and color. Useful for creating distinct content sections with depth.

Parameters:

  • child: The widget to be wrapped in the elevated card.
  • elevation: The shadow depth of the card (defaults to 4).
  • padding: Internal padding for the child widget. Uses Utils.appConstants.boxPadding if null.
  • borderRadius: Corner radius of the card. Uses Utils.appConstants.toolbarImageRadius if null.
  • verticalMargin: Vertical spacing around the card (defaults to 8.0).
  • color: Background color of the card (defaults to white).

Returns a Card widget with the specified styling.

Example:

getBoxWithElevation(
  child: Text('Content'),
  elevation: 6,
  padding: 16,
  borderRadius: 12,
  color: Colors.grey[100],
);

Implementation

Widget getBoxWithElevation(
    {required Widget child,
    double elevation = 4,
    double? padding,
    double? borderRadius,
    double verticalMargin = 8.0,
    Color color = Colors.white}) {
  return Card(
    elevation: elevation,
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.circular(
          borderRadius ?? Utils.appConstants.toolbarImageRadius),
    ),
    margin: EdgeInsets.symmetric(vertical: verticalMargin),
    color: color,
    child: Padding(
      padding: EdgeInsets.all(padding ?? Utils.appConstants.boxPadding),
      child: child,
    ),
  );
}