Skip to content

Instantly share code, notes, and snippets.

@juancavallotti
Created February 2, 2023 21:41
Show Gist options
  • Save juancavallotti/2922abfa5bce8672cd9ad3acd2aac5e7 to your computer and use it in GitHub Desktop.
Save juancavallotti/2922abfa5bce8672cd9ad3acd2aac5e7 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
extension QuickPadding on Widget {
Widget padding(
{double? all,
double top = 0,
double bottom = 0,
double left = 0,
double right = 0}) {
EdgeInsets insets = (all != null)
? EdgeInsets.all(all)
: EdgeInsets.only(bottom: bottom, top: top, left: left, right: right);
return Padding(
padding: insets,
child: this,
);
}
}
extension QuickSizedBox on Widget {
Widget sizedBox({double? width, double? height}) {
return SizedBox(
width: width,
height: height,
child: this,
);
}
Widget boxExpand() {
return SizedBox.expand(
child: this,
);
}
}
extension QuickColumn on List<Widget> {
Widget column(
{CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.center,
MainAxisAlignment mainAxisAlignment = MainAxisAlignment.center}) {
return Column(
crossAxisAlignment: crossAxisAlignment,
mainAxisAlignment: mainAxisAlignment,
children: this,
);
}
}
extension QuickContainer on Widget {
Widget container({Decoration? decoration}) {
return Container(
decoration: decoration,
child: this,
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment