Flutter DSL (Domain Specific Language)
extension WidgetStyling on Widget {
Widget paddingAll(double value) => Padding(
padding: EdgeInsets.all(value),
child: this,
);
Widget roundedBox({
Color color = Colors.white,
double radius = 12,
}) {
return Container(
decoration: BoxDecoration(
color: color,
borderRadius: BorderRadius.circular(radius),
),
child: this,
);
}
Widget shadow({double blur = 8.0}) {
return Container(
decoration: BoxDecoration(
boxShadow: [
BoxShadow(color: Colors.black12, blurRadius: blur),
],
),
child: this,
);
}
}
✅ Usage:
Text("Styled Box")
.paddingAll(12)
.roundedBox(color: Colors.grey[200]!)
.shadow()Last updated