Showing
3 changed files
with
21 additions
and
4 deletions
@@ -160,6 +160,16 @@ class RxBool extends _RxImpl<bool> { | @@ -160,6 +160,16 @@ class RxBool extends _RxImpl<bool> { | ||
160 | RxBool([bool initial]) { | 160 | RxBool([bool initial]) { |
161 | _value = initial; | 161 | _value = initial; |
162 | } | 162 | } |
163 | + | ||
164 | + bool operator &(bool other) => other && value; | ||
165 | + | ||
166 | + bool operator |(bool other) => other || value; | ||
167 | + | ||
168 | + bool operator ^(bool other) => !other == value; | ||
169 | + | ||
170 | + String toString() { | ||
171 | + return value ? "true" : "false"; | ||
172 | + } | ||
163 | } | 173 | } |
164 | 174 | ||
165 | class RxDouble extends _RxImpl<double> { | 175 | class RxDouble extends _RxImpl<double> { |
@@ -3,7 +3,7 @@ import 'package:get/get.dart'; | @@ -3,7 +3,7 @@ import 'package:get/get.dart'; | ||
3 | import '../rx_core/rx_interface.dart'; | 3 | import '../rx_core/rx_interface.dart'; |
4 | import 'utils/debouncer.dart'; | 4 | import 'utils/debouncer.dart'; |
5 | 5 | ||
6 | -Worker ever(RxInterface listener, Function(dynamic) callback, | 6 | +Worker ever<T>(RxInterface<T> listener, Function(T) callback, |
7 | {bool condition = true}) { | 7 | {bool condition = true}) { |
8 | StreamSubscription sub = listener.subject.stream.listen((event) { | 8 | StreamSubscription sub = listener.subject.stream.listen((event) { |
9 | if (condition) callback(event); | 9 | if (condition) callback(event); |
@@ -37,7 +37,7 @@ Worker everAll(List<RxInterface> listener, Function(dynamic) callback, | @@ -37,7 +37,7 @@ Worker everAll(List<RxInterface> listener, Function(dynamic) callback, | ||
37 | return Worker(cancel, '[everAll]'); | 37 | return Worker(cancel, '[everAll]'); |
38 | } | 38 | } |
39 | 39 | ||
40 | -Worker once(RxInterface listener, Function(dynamic) callback, | 40 | +Worker once<T>(RxInterface<T> listener, Function(T) callback, |
41 | {bool condition = true}) { | 41 | {bool condition = true}) { |
42 | StreamSubscription sub; | 42 | StreamSubscription sub; |
43 | int times = 0; | 43 | int times = 0; |
@@ -59,7 +59,7 @@ Worker once(RxInterface listener, Function(dynamic) callback, | @@ -59,7 +59,7 @@ Worker once(RxInterface listener, Function(dynamic) callback, | ||
59 | return Worker(cancel, '[once]'); | 59 | return Worker(cancel, '[once]'); |
60 | } | 60 | } |
61 | 61 | ||
62 | -Worker interval(RxInterface listener, Function(dynamic) callback, | 62 | +Worker interval<T>(RxInterface<T> listener, Function(T) callback, |
63 | {Duration time, bool condition = true}) { | 63 | {Duration time, bool condition = true}) { |
64 | bool debounceActive = false; | 64 | bool debounceActive = false; |
65 | StreamSubscription sub = listener.subject.stream.listen((event) async { | 65 | StreamSubscription sub = listener.subject.stream.listen((event) async { |
@@ -77,7 +77,7 @@ Worker interval(RxInterface listener, Function(dynamic) callback, | @@ -77,7 +77,7 @@ Worker interval(RxInterface listener, Function(dynamic) callback, | ||
77 | return Worker(cancel, '[interval]'); | 77 | return Worker(cancel, '[interval]'); |
78 | } | 78 | } |
79 | 79 | ||
80 | -Worker debounce(RxInterface listener, Function(dynamic) callback, | 80 | +Worker debounce<T>(RxInterface<T> listener, Function(T) callback, |
81 | {Duration time}) { | 81 | {Duration time}) { |
82 | final _debouncer = Debouncer(delay: time ?? Duration(milliseconds: 800)); | 82 | final _debouncer = Debouncer(delay: time ?? Duration(milliseconds: 800)); |
83 | StreamSubscription sub = listener.subject.stream.listen((event) { | 83 | StreamSubscription sub = listener.subject.stream.listen((event) { |
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); |
@@ -47,3 +49,8 @@ extension WidgetMarginX on Widget { | @@ -47,3 +49,8 @@ extension WidgetMarginX on Widget { | ||
47 | 49 | ||
48 | Widget get marginZero => Container(margin: EdgeInsets.zero, child: this); | 50 | Widget get marginZero => Container(margin: EdgeInsets.zero, child: this); |
49 | } | 51 | } |
52 | + | ||
53 | +/// Allows you to insert widgets inside a CustomScrollView | ||
54 | +extension WidgetSliverBoxX on Widget { | ||
55 | + Widget get sliverBox => SliverToBoxAdapter(child: this); | ||
56 | +} |
-
Please register or login to post a comment