Skip to content

Instantly share code, notes, and snippets.

@amerblackbird
Last active February 24, 2023 14:33
Show Gist options
  • Save amerblackbird/b4863f58532d892d4c8002380651588e to your computer and use it in GitHub Desktop.
Save amerblackbird/b4863f58532d892d4c8002380651588e to your computer and use it in GitHub Desktop.
Flutter int and double padding extension
/// Creates padding from int using extension
extension IntPaddingExtension on int {
/// Padding
EdgeInsets get p => EdgeInsets.all(toDouble());
/// Top padding
EdgeInsets get pt => EdgeInsets.only(top: toDouble());
/// Left padding
EdgeInsets get pl => EdgeInsets.only(left: toDouble());
/// Right padding
EdgeInsets get pr => EdgeInsets.only(right: toDouble());
/// Bottom padding
EdgeInsets get pb => EdgeInsets.only(bottom: toDouble());
/// Vertical padding
EdgeInsets get pv => EdgeInsets.symmetric(vertical: toDouble());
/// Horizontal padding
EdgeInsets get ph => EdgeInsets.symmetric(horizontal: toDouble());
}
/// Creates padding from double using extension
extension DoublePaddingExtension on double {
/// Padding
EdgeInsets get p => EdgeInsets.all(this);
/// Top padding
EdgeInsets get pt => EdgeInsets.only(top: this);
/// Left padding
EdgeInsets get pl => EdgeInsets.only(left: this);
/// Right padding
EdgeInsets get pr => EdgeInsets.only(right: this);
/// Bottom padding
EdgeInsets get pb => EdgeInsets.only(bottom: this);
/// Vertical padding
EdgeInsets get pv => EdgeInsets.symmetric(vertical: this);
/// Horizontal padding
EdgeInsets get ph => EdgeInsets.symmetric(horizontal: this);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment