Showing
1 changed file
with
5 additions
and
2 deletions
| 1 | import 'package:flutter/widgets.dart'; | 1 | import 'package:flutter/widgets.dart'; | 
| 2 | 2 | ||
| 3 | +/// add Padding Property to widget | ||
| 3 | extension WidgetPaddingX on Widget { | 4 | extension WidgetPaddingX on Widget { | 
| 4 | Widget paddingAll(double padding) => | 5 | Widget paddingAll(double padding) => | 
| 5 | Padding(padding: EdgeInsets.all(padding), child: this); | 6 | Padding(padding: EdgeInsets.all(padding), child: this); | 
| @@ -24,6 +25,7 @@ extension WidgetPaddingX on Widget { | @@ -24,6 +25,7 @@ extension WidgetPaddingX on Widget { | ||
| 24 | Widget get paddingZero => Padding(padding: EdgeInsets.zero, child: this); | 25 | Widget get paddingZero => Padding(padding: EdgeInsets.zero, child: this); | 
| 25 | } | 26 | } | 
| 26 | 27 | ||
| 28 | +/// Add margin property to widget | ||
| 27 | extension WidgetMarginX on Widget { | 29 | extension WidgetMarginX on Widget { | 
| 28 | Widget marginAll(double margin) => | 30 | Widget marginAll(double margin) => | 
| 29 | Container(margin: EdgeInsets.all(margin), child: this); | 31 | Container(margin: EdgeInsets.all(margin), child: this); | 
| @@ -33,14 +35,14 @@ extension WidgetMarginX on Widget { | @@ -33,14 +35,14 @@ extension WidgetMarginX on Widget { | ||
| 33 | margin: | 35 | margin: | 
| 34 | EdgeInsets.symmetric(horizontal: horizontal, vertical: vertical), | 36 | EdgeInsets.symmetric(horizontal: horizontal, vertical: vertical), | 
| 35 | child: this); | 37 | child: this); | 
| 36 | - | 38 | + | 
| 37 | Widget marginOnly({ | 39 | Widget marginOnly({ | 
| 38 | double left = 0.0, | 40 | double left = 0.0, | 
| 39 | double top = 0.0, | 41 | double top = 0.0, | 
| 40 | double right = 0.0, | 42 | double right = 0.0, | 
| 41 | double bottom = 0.0, | 43 | double bottom = 0.0, | 
| 42 | }) => | 44 | }) => | 
| 43 | - Container( | 45 | + Padding( | 
| 44 | margin: EdgeInsets.only( | 46 | margin: EdgeInsets.only( | 
| 45 | top: top, left: left, right: right, bottom: bottom), | 47 | top: top, left: left, right: right, bottom: bottom), | 
| 46 | child: this); | 48 | child: this); | 
| @@ -48,6 +50,7 @@ extension WidgetMarginX on Widget { | @@ -48,6 +50,7 @@ extension WidgetMarginX on Widget { | ||
| 48 | Widget get marginZero => Container(margin: EdgeInsets.zero, child: this); | 50 | Widget get marginZero => Container(margin: EdgeInsets.zero, child: this); | 
| 49 | } | 51 | } | 
| 50 | 52 | ||
| 53 | +/// Allows you to insert widgets inside a CustomScrollView | ||
| 51 | extension WidgetSliverBoxX on Widget { | 54 | extension WidgetSliverBoxX on Widget { | 
| 52 | Widget get sliverBox => SliverToBoxAdapter(child: this); | 55 | Widget get sliverBox => SliverToBoxAdapter(child: this); | 
| 53 | } | 56 | } | 
- 
Please register or login to post a comment