Showing
7 changed files
with
80 additions
and
16 deletions
1 | +## [4.0.1] | ||
2 | +- Fix changelog | ||
3 | + | ||
1 | ## [4.0.0] | 4 | ## [4.0.0] |
2 | - Added append function to StateMixin. Now is possible track loading, success and error handle of your application with ONE LINE OF CODE. Ex: append(()=> api.getUser); | 5 | - Added append function to StateMixin. Now is possible track loading, success and error handle of your application with ONE LINE OF CODE. Ex: append(()=> api.getUser); |
3 | - Migrate to null-safety | 6 | - Migrate to null-safety |
4 | - Added ScrollMixin to controllers | 7 | - Added ScrollMixin to controllers |
5 | - Added loadingMore status to RxStatus | 8 | - Added loadingMore status to RxStatus |
6 | -- Breaking: It is not possible to initialize Rx with null values. | 9 | +- Fix content-type qual null (@katekko) |
10 | +- Made GetInstance non nullable (@eduardoflorence) | ||
11 | +- Fix multi-parameters url (@iMrLopez) | ||
12 | +- Fix Expected value of SkDeletable error (@obadajasm) | ||
13 | +- Added triggers, an Rx method that triggers events, even if they are the same as the previous event (@RafaRuiz) | ||
14 | +- Improve docs: (@CNAD666), (@dhhAndroid), (@Jackylee1992), | ||
15 | + | ||
16 | +Switching to null-safety: | ||
17 | +You can continue using GetX as normal, with as little breaking changes as possible. | ||
18 | +It is still possible to declare the var.obs variable, and this remains the preferred way, forcing null-safety and giving you all the security that sound null-safety delivers to your app. However, if you need to use null, we also provide a solution for you. | ||
19 | +Declare the variables with `?` Ex: `final Rx<int?> count = 0.obs`. | ||
20 | +You can also use custom Rxn types with null-safety: | ||
21 | +`RxInt` == not nullable | ||
22 | +`RxnInt` == nullable. | ||
7 | 23 | ||
8 | ## [3.25.6] | 24 | ## [3.25.6] |
9 | - Added documentation in French (@kamazoun) | 25 | - Added documentation in French (@kamazoun) |
@@ -20,6 +20,7 @@ linter: | @@ -20,6 +20,7 @@ linter: | ||
20 | # INCLUDE_FIX (copy of effective dart 1.2.0) | 20 | # INCLUDE_FIX (copy of effective dart 1.2.0) |
21 | # STYLE | 21 | # STYLE |
22 | camel_case_types: true | 22 | camel_case_types: true |
23 | + close_sinks: true | ||
23 | camel_case_extensions: true | 24 | camel_case_extensions: true |
24 | library_names: true | 25 | library_names: true |
25 | file_names: true | 26 | file_names: true |
@@ -90,7 +90,7 @@ class BaseWebSocket { | @@ -90,7 +90,7 @@ class BaseWebSocket { | ||
90 | } | 90 | } |
91 | 91 | ||
92 | void close([int? status, String? reason]) { | 92 | void close([int? status, String? reason]) { |
93 | - if (socket != null) socket!.close(status, reason); | 93 | + socket?.close(status, reason); |
94 | } | 94 | } |
95 | 95 | ||
96 | void send(dynamic data) { | 96 | void send(dynamic data) { |
@@ -82,9 +82,7 @@ class BaseWebSocket { | @@ -82,9 +82,7 @@ class BaseWebSocket { | ||
82 | } | 82 | } |
83 | 83 | ||
84 | void close([int? status, String? reason]) { | 84 | void close([int? status, String? reason]) { |
85 | - if (socket != null) { | ||
86 | - socket!.close(status, reason); | ||
87 | - } | 85 | + socket?.close(status, reason); |
88 | } | 86 | } |
89 | 87 | ||
90 | void send(dynamic data) async { | 88 | void send(dynamic data) async { |
@@ -95,9 +95,11 @@ mixin RxObjectMixin<T> on NotifyManager<T> { | @@ -95,9 +95,11 @@ mixin RxObjectMixin<T> on NotifyManager<T> { | ||
95 | /// Updates the [value] and adds it to the stream, updating the observer | 95 | /// Updates the [value] and adds it to the stream, updating the observer |
96 | /// Widget, only if it's different from the previous value. | 96 | /// Widget, only if it's different from the previous value. |
97 | set value(T val) { | 97 | set value(T val) { |
98 | + if (subject.isClosed) return; | ||
98 | if (_value == val && !firstRebuild) return; | 99 | if (_value == val && !firstRebuild) return; |
99 | firstRebuild = false; | 100 | firstRebuild = false; |
100 | _value = val; | 101 | _value = val; |
102 | + | ||
101 | subject.add(_value); | 103 | subject.add(_value); |
102 | } | 104 | } |
103 | 105 | ||
@@ -236,15 +238,32 @@ abstract class _RxImpl<T> extends RxNotifier<T> with RxObjectMixin<T> { | @@ -236,15 +238,32 @@ abstract class _RxImpl<T> extends RxNotifier<T> with RxObjectMixin<T> { | ||
236 | } | 238 | } |
237 | } | 239 | } |
238 | 240 | ||
239 | -extension RxBoolExt on Rx<bool> {} | ||
240 | - | ||
241 | -/// Rx class for `bool` Type. | ||
242 | -class RxBool extends _RxImpl<bool> { | 241 | +class RxBool extends Rx<bool> { |
243 | RxBool(bool initial) : super(initial); | 242 | RxBool(bool initial) : super(initial); |
243 | + @override | ||
244 | + String toString() { | ||
245 | + return value ? "true" : "false"; | ||
246 | + } | ||
247 | +} | ||
244 | 248 | ||
245 | - bool? get isTrue => value; | 249 | +class RxnBool extends Rx<bool?> { |
250 | + RxnBool(bool initial) : super(initial); | ||
251 | + @override | ||
252 | + String toString() { | ||
253 | + if (value == null) { | ||
254 | + return "null"; | ||
255 | + } else if (value) { | ||
256 | + return "true"; | ||
257 | + } else { | ||
258 | + return "false"; | ||
259 | + } | ||
260 | + } | ||
261 | +} | ||
262 | + | ||
263 | +extension RxBoolExt on Rx<bool> { | ||
264 | + bool get isTrue => value; | ||
246 | 265 | ||
247 | - bool get isFalse => !isTrue!; | 266 | + bool get isFalse => !isTrue; |
248 | 267 | ||
249 | bool operator &(bool other) => other && value; | 268 | bool operator &(bool other) => other && value; |
250 | 269 | ||
@@ -257,14 +276,43 @@ class RxBool extends _RxImpl<bool> { | @@ -257,14 +276,43 @@ class RxBool extends _RxImpl<bool> { | ||
257 | /// FIXME: why return this? fluent interface is not | 276 | /// FIXME: why return this? fluent interface is not |
258 | /// not really a dart thing since we have '..' operator | 277 | /// not really a dart thing since we have '..' operator |
259 | // ignore: avoid_returning_this | 278 | // ignore: avoid_returning_this |
260 | - RxBool toggle() { | 279 | + Rx<bool> toggle() { |
261 | subject.add(_value = !_value); | 280 | subject.add(_value = !_value); |
262 | return this; | 281 | return this; |
263 | } | 282 | } |
283 | +} | ||
264 | 284 | ||
265 | - @override | ||
266 | - String toString() { | ||
267 | - return value ? "true" : "false"; | 285 | +extension RxnBoolExt on Rx<bool?> { |
286 | + bool? get isTrue => value; | ||
287 | + | ||
288 | + bool? get isFalse { | ||
289 | + if (value != null) return !isTrue!; | ||
290 | + } | ||
291 | + | ||
292 | + bool? operator &(bool other) { | ||
293 | + if (value != null) { | ||
294 | + return other && value!; | ||
295 | + } | ||
296 | + } | ||
297 | + | ||
298 | + bool? operator |(bool other) { | ||
299 | + if (value != null) { | ||
300 | + return other || value!; | ||
301 | + } | ||
302 | + } | ||
303 | + | ||
304 | + bool? operator ^(bool other) => !other == value; | ||
305 | + | ||
306 | + /// Toggles the bool [value] between false and true. | ||
307 | + /// A shortcut for `flag.value = !flag.value;` | ||
308 | + /// FIXME: why return this? fluent interface is not | ||
309 | + /// not really a dart thing since we have '..' operator | ||
310 | + // ignore: avoid_returning_this | ||
311 | + Rx<bool?>? toggle() { | ||
312 | + if (_value != null) { | ||
313 | + subject.add(_value = !_value!); | ||
314 | + return this; | ||
315 | + } | ||
268 | } | 316 | } |
269 | } | 317 | } |
270 | 318 |
1 | name: get | 1 | name: get |
2 | description: Open screens/snackbars/dialogs without context, manage states and inject dependencies easily with GetX. | 2 | description: Open screens/snackbars/dialogs without context, manage states and inject dependencies easily with GetX. |
3 | -version: 4.0.0 | 3 | +version: 4.0.1 |
4 | homepage: https://github.com/jonataslaw/getx | 4 | homepage: https://github.com/jonataslaw/getx |
5 | 5 | ||
6 | environment: | 6 | environment: |
@@ -94,6 +94,7 @@ void main() { | @@ -94,6 +94,7 @@ void main() { | ||
94 | 94 | ||
95 | await Future.delayed(Duration.zero); | 95 | await Future.delayed(Duration.zero); |
96 | expect(count, 555); | 96 | expect(count, 555); |
97 | + controller.close(); | ||
97 | }); | 98 | }); |
98 | 99 | ||
99 | test('Rx same value will not call the same listener when `call`', () async { | 100 | test('Rx same value will not call the same listener when `call`', () async { |
-
Please register or login to post a comment