getRoundedBackground method
Creates a rounded container with a colored background.
This widget wraps a child in a Container with rounded corners and consistent padding, useful for creating badges, tags, or highlighted content areas.
Parameters:
child: The widget to be wrapped in the rounded background.backgroundColor: The background color of the container.width: Optional width constraint for the container.
Returns a Container with rounded corners (12px radius) and symmetric padding.
Example:
getRoundedBackground(
Text('New'),
Colors.red,
width: 60,
);
Implementation
Widget getRoundedBackground(Widget child, Color backgroundColor,
{double? width}) {
return Container(
width: width,
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0),
decoration: BoxDecoration(
color: backgroundColor,
borderRadius: BorderRadius.circular(12.0),
),
child: child,
);
}