Last active
February 24, 2023 14:33
-
-
Save amerblackbird/b4863f58532d892d4c8002380651588e to your computer and use it in GitHub Desktop.
Flutter int and double padding extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 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