@@ -633,6 +633,14 @@ extension NyColumn on Column {
633633 child: this ,
634634 );
635635 }
636+
637+ /// Make a widget visible when a condition is true.
638+ Widget visibleWhen (bool condition) {
639+ return Visibility (
640+ visible: condition,
641+ child: this ,
642+ );
643+ }
636644}
637645
638646/// Extensions for [Image]
@@ -766,20 +774,28 @@ extension NySingleChildRenderObjectWidget on SingleChildRenderObjectWidget {
766774 child: this ,
767775 );
768776 }
777+
778+ /// Make a widget visible when a condition is true.
779+ Widget visibleWhen (bool condition) {
780+ return Visibility (
781+ visible: condition,
782+ child: this ,
783+ );
784+ }
769785}
770786
771787/// Extensions for [String]
772788extension NyString on String {
773789 /// dump the value to the console.
774790 /// [tag] is optional.
775791 /// [alwaysPrint] is optional.
776- dump ({String ? tag, bool alwaysPrint = false }) {
792+ void dump ({String ? tag, bool alwaysPrint = false }) {
777793 NyLogger .dump (toString (), tag, alwaysPrint: alwaysPrint);
778794 }
779795
780796 /// dump the value to the console and exit the app.
781797 /// [tag] is optional.
782- dd ({String ? tag}) {
798+ void dd ({String ? tag}) {
783799 NyLogger .dump (toString (), tag);
784800 exit (0 );
785801 }
@@ -887,6 +903,14 @@ extension NyStatelessWidget on StatelessWidget {
887903 );
888904 }
889905
906+ /// Make a widget visible when a condition is true.
907+ Widget visibleWhen (bool condition) {
908+ return Visibility (
909+ visible: condition,
910+ child: this ,
911+ );
912+ }
913+
890914 /// Add a shadow to the container.
891915 Container shadow (int strength,
892916 {Color ? color,
@@ -1145,6 +1169,14 @@ extension NyBoxScrollView on BoxScrollView {
11451169 child: this ,
11461170 );
11471171 }
1172+
1173+ /// Make a widget visible when a condition is true.
1174+ Widget visibleWhen (bool condition) {
1175+ return Visibility (
1176+ visible: condition,
1177+ child: this ,
1178+ );
1179+ }
11481180}
11491181
11501182/// Extensions for [Row]
@@ -1244,6 +1276,14 @@ extension NyRow on Row {
12441276 ),
12451277 );
12461278 }
1279+
1280+ /// Make a widget visible when a condition is true.
1281+ Widget visibleWhen (bool condition) {
1282+ return Visibility (
1283+ visible: condition,
1284+ child: this ,
1285+ );
1286+ }
12471287}
12481288
12491289/// Extensions for [Text]
0 commit comments