getBoxWithElevation method
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. UsesUtils.appConstants.boxPaddingif null.borderRadius: Corner radius of the card. UsesUtils.appConstants.toolbarImageRadiusif 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,
),
);
}