Jonny Borges

fix workers with null safety

@@ -23,7 +23,7 @@ jobs: @@ -23,7 +23,7 @@ jobs:
23 # https://github.com/marketplace/actions/flutter-action 23 # https://github.com/marketplace/actions/flutter-action
24 - uses: subosito/flutter-action@v1 24 - uses: subosito/flutter-action@v1
25 with: 25 with:
26 - flutter-version: "1.22.3" 26 + flutter-version: "2.0.2"
27 channel: "stable" 27 channel: "stable"
28 - run: flutter pub get 28 - run: flutter pub get
29 #- run: flutter analyze 29 #- run: flutter analyze
@@ -33,6 +33,7 @@ @@ -33,6 +33,7 @@
33 /ios/ 33 /ios/
34 /android/ 34 /android/
35 /web/ 35 /web/
  36 +/macos/
36 37
37 # Web related 38 # Web related
38 lib/generated_plugin_registrant.dart 39 lib/generated_plugin_registrant.dart
@@ -86,6 +86,16 @@ void main() { @@ -86,6 +86,16 @@ void main() {
86 } 86 }
87 }); 87 });
88 88
  89 + test('ever', () async {
  90 + RxString count = ''.obs;
  91 + var result = '';
  92 + ever<String>(count, (value) {
  93 + result = value;
  94 + });
  95 + count.value = '1';
  96 + expect('1', result);
  97 + });
  98 +
89 /// Tests with GetTests 99 /// Tests with GetTests
90 /// TEMPORARILY REMOVED from the null-safetym branch as 100 /// TEMPORARILY REMOVED from the null-safetym branch as
91 /// get_test is not yet null safety. 101 /// get_test is not yet null safety.
@@ -93,16 +93,17 @@ class ParseRouteTree { @@ -93,16 +93,17 @@ class ParseRouteTree {
93 ); 93 );
94 } 94 }
95 95
96 -  
97 Map<String, String?> _parseParams(String path, PathDecoded routePath) { 96 Map<String, String?> _parseParams(String path, PathDecoded routePath) {
98 final params = <String, String?>{}; 97 final params = <String, String?>{};
99 var idx = path.indexOf('?'); 98 var idx = path.indexOf('?');
100 if (idx > -1) { 99 if (idx > -1) {
101 path = path.substring(0, idx); 100 path = path.substring(0, idx);
102 final uri = Uri.tryParse(path); 101 final uri = Uri.tryParse(path);
  102 + if (uri != null) {
103 params.addAll(uri.queryParameters); 103 params.addAll(uri.queryParameters);
104 } 104 }
105 - Match paramsMatch = routePath.regex.firstMatch(path); 105 + }
  106 + var paramsMatch = routePath.regex.firstMatch(path);
106 107
107 for (var i = 0; i < routePath.keys.length; i++) { 108 for (var i = 0; i < routePath.keys.length; i++) {
108 var param = Uri.decodeQueryComponent(paramsMatch![i + 1]!); 109 var param = Uri.decodeQueryComponent(paramsMatch![i + 1]!);
@@ -225,7 +225,7 @@ abstract class _RxImpl<T> extends RxNotifier<T> with RxObjectMixin<T> { @@ -225,7 +225,7 @@ abstract class _RxImpl<T> extends RxNotifier<T> with RxObjectMixin<T> {
225 /// secondsRx.trigger(2); // This will trigger the listener independently from the value. 225 /// secondsRx.trigger(2); // This will trigger the listener independently from the value.
226 /// ``` 226 /// ```
227 /// 227 ///
228 - void trigger([T v]) { 228 + void trigger(T v) {
229 var firstRebuild = this.firstRebuild; 229 var firstRebuild = this.firstRebuild;
230 value = v; 230 value = v;
231 // If it's not the first rebuild, the listeners have been called already 231 // If it's not the first rebuild, the listeners have been called already
@@ -237,16 +237,16 @@ abstract class _RxImpl<T> extends RxNotifier<T> with RxObjectMixin<T> { @@ -237,16 +237,16 @@ abstract class _RxImpl<T> extends RxNotifier<T> with RxObjectMixin<T> {
237 } 237 }
238 238
239 /// Rx class for `bool` Type. 239 /// Rx class for `bool` Type.
240 -class RxBool extends _RxImpl<bool?> {  
241 - RxBool([bool? initial]) : super(initial); 240 +class RxBool extends _RxImpl<bool> {
  241 + RxBool(bool initial) : super(initial);
242 242
243 bool? get isTrue => value; 243 bool? get isTrue => value;
244 244
245 bool get isFalse => !isTrue!; 245 bool get isFalse => !isTrue!;
246 246
247 - bool operator &(bool other) => other && value!; 247 + bool operator &(bool other) => other && value;
248 248
249 - bool operator |(bool other) => other || value!; 249 + bool operator |(bool other) => other || value;
250 250
251 bool operator ^(bool other) => !other == value; 251 bool operator ^(bool other) => !other == value;
252 252
@@ -256,53 +256,53 @@ class RxBool extends _RxImpl<bool?> { @@ -256,53 +256,53 @@ class RxBool extends _RxImpl<bool?> {
256 /// not really a dart thing since we have '..' operator 256 /// not really a dart thing since we have '..' operator
257 // ignore: avoid_returning_this 257 // ignore: avoid_returning_this
258 RxBool toggle() { 258 RxBool toggle() {
259 - subject.add(_value = !_value!); 259 + subject.add(_value = !_value);
260 return this; 260 return this;
261 } 261 }
262 262
263 @override 263 @override
264 String toString() { 264 String toString() {
265 - return value! ? "true" : "false"; 265 + return value ? "true" : "false";
266 } 266 }
267 } 267 }
268 268
269 /// Rx class for `String` Type. 269 /// Rx class for `String` Type.
270 -class RxString extends _RxImpl<String?> implements Comparable<String>, Pattern {  
271 - RxString([String? initial]) : super(initial); 270 +class RxString extends _RxImpl<String> implements Comparable<String>, Pattern {
  271 + RxString(String initial) : super(initial);
272 272
273 - String operator +(String val) => _value! + val; 273 + String operator +(String val) => _value + val;
274 274
275 /// Compares this string to [other]. 275 /// Compares this string to [other].
276 @override 276 @override
277 int compareTo(String other) { 277 int compareTo(String other) {
278 - return value!.compareTo(other); 278 + return value.compareTo(other);
279 } 279 }
280 280
281 /// Returns true if this string ends with [other]. For example: 281 /// Returns true if this string ends with [other]. For example:
282 /// 282 ///
283 /// 'Dart'.endsWith('t'); // true 283 /// 'Dart'.endsWith('t'); // true
284 bool endsWith(String other) { 284 bool endsWith(String other) {
285 - return value!.endsWith(other); 285 + return value.endsWith(other);
286 } 286 }
287 287
288 /// Returns true if this string starts with a match of [pattern]. 288 /// Returns true if this string starts with a match of [pattern].
289 bool startsWith(Pattern pattern, [int index = 0]) { 289 bool startsWith(Pattern pattern, [int index = 0]) {
290 - return value!.startsWith(pattern, index); 290 + return value.startsWith(pattern, index);
291 } 291 }
292 292
293 /// Returns the position of the first match of [pattern] in this string 293 /// Returns the position of the first match of [pattern] in this string
294 int indexOf(Pattern pattern, [int start = 0]) { 294 int indexOf(Pattern pattern, [int start = 0]) {
295 - return value!.indexOf(pattern, start); 295 + return value.indexOf(pattern, start);
296 } 296 }
297 297
298 /// Returns the starting position of the last match [pattern] in this string, 298 /// Returns the starting position of the last match [pattern] in this string,
299 /// searching backward starting at [start], inclusive: 299 /// searching backward starting at [start], inclusive:
300 int lastIndexOf(Pattern pattern, [int? start]) { 300 int lastIndexOf(Pattern pattern, [int? start]) {
301 - return value!.lastIndexOf(pattern, start); 301 + return value.lastIndexOf(pattern, start);
302 } 302 }
303 303
304 /// Returns true if this string is empty. 304 /// Returns true if this string is empty.
305 - bool get isEmpty => value!.isEmpty; 305 + bool get isEmpty => value.isEmpty;
306 306
307 /// Returns true if this string is not empty. 307 /// Returns true if this string is not empty.
308 bool get isNotEmpty => !isEmpty; 308 bool get isNotEmpty => !isEmpty;
@@ -310,26 +310,26 @@ class RxString extends _RxImpl<String?> implements Comparable<String>, Pattern { @@ -310,26 +310,26 @@ class RxString extends _RxImpl<String?> implements Comparable<String>, Pattern {
310 /// Returns the substring of this string that extends from [startIndex], 310 /// Returns the substring of this string that extends from [startIndex],
311 /// inclusive, to [endIndex], exclusive 311 /// inclusive, to [endIndex], exclusive
312 String substring(int startIndex, [int? endIndex]) { 312 String substring(int startIndex, [int? endIndex]) {
313 - return value!.substring(startIndex, endIndex); 313 + return value.substring(startIndex, endIndex);
314 } 314 }
315 315
316 /// Returns the string without any leading and trailing whitespace. 316 /// Returns the string without any leading and trailing whitespace.
317 String trim() { 317 String trim() {
318 - return value!.trim(); 318 + return value.trim();
319 } 319 }
320 320
321 /// Returns the string without any leading whitespace. 321 /// Returns the string without any leading whitespace.
322 /// 322 ///
323 /// As [trim], but only removes leading whitespace. 323 /// As [trim], but only removes leading whitespace.
324 String trimLeft() { 324 String trimLeft() {
325 - return value!.trimLeft(); 325 + return value.trimLeft();
326 } 326 }
327 327
328 /// Returns the string without any trailing whitespace. 328 /// Returns the string without any trailing whitespace.
329 /// 329 ///
330 /// As [trim], but only removes trailing whitespace. 330 /// As [trim], but only removes trailing whitespace.
331 String trimRight() { 331 String trimRight() {
332 - return value!.trimRight(); 332 + return value.trimRight();
333 } 333 }
334 334
335 /// Pads this string on the left if it is shorter than [width]. 335 /// Pads this string on the left if it is shorter than [width].
@@ -337,7 +337,7 @@ class RxString extends _RxImpl<String?> implements Comparable<String>, Pattern { @@ -337,7 +337,7 @@ class RxString extends _RxImpl<String?> implements Comparable<String>, Pattern {
337 /// Return a new string that prepends [padding] onto this string 337 /// Return a new string that prepends [padding] onto this string
338 /// one time for each position the length is less than [width]. 338 /// one time for each position the length is less than [width].
339 String padLeft(int width, [String padding = ' ']) { 339 String padLeft(int width, [String padding = ' ']) {
340 - return value!.padLeft(width, padding); 340 + return value.padLeft(width, padding);
341 } 341 }
342 342
343 /// Pads this string on the right if it is shorter than [width]. 343 /// Pads this string on the right if it is shorter than [width].
@@ -345,55 +345,55 @@ class RxString extends _RxImpl<String?> implements Comparable<String>, Pattern { @@ -345,55 +345,55 @@ class RxString extends _RxImpl<String?> implements Comparable<String>, Pattern {
345 /// Return a new string that appends [padding] after this string 345 /// Return a new string that appends [padding] after this string
346 /// one time for each position the length is less than [width]. 346 /// one time for each position the length is less than [width].
347 String padRight(int width, [String padding = ' ']) { 347 String padRight(int width, [String padding = ' ']) {
348 - return value!.padRight(width, padding); 348 + return value.padRight(width, padding);
349 } 349 }
350 350
351 /// Returns true if this string contains a match of [other]: 351 /// Returns true if this string contains a match of [other]:
352 bool contains(Pattern other, [int startIndex = 0]) { 352 bool contains(Pattern other, [int startIndex = 0]) {
353 - return value!.contains(other, startIndex); 353 + return value.contains(other, startIndex);
354 } 354 }
355 355
356 /// Replaces all substrings that match [from] with [replace]. 356 /// Replaces all substrings that match [from] with [replace].
357 String replaceAll(Pattern from, String replace) { 357 String replaceAll(Pattern from, String replace) {
358 - return value!.replaceAll(from, replace); 358 + return value.replaceAll(from, replace);
359 } 359 }
360 360
361 /// Splits the string at matches of [pattern] and returns a list 361 /// Splits the string at matches of [pattern] and returns a list
362 /// of substrings. 362 /// of substrings.
363 List<String> split(Pattern pattern) { 363 List<String> split(Pattern pattern) {
364 - return value!.split(pattern); 364 + return value.split(pattern);
365 } 365 }
366 366
367 /// Returns an unmodifiable list of the UTF-16 code units of this string. 367 /// Returns an unmodifiable list of the UTF-16 code units of this string.
368 - List<int> get codeUnits => value!.codeUnits; 368 + List<int> get codeUnits => value.codeUnits;
369 369
370 /// Returns an [Iterable] of Unicode code-points of this string. 370 /// Returns an [Iterable] of Unicode code-points of this string.
371 /// 371 ///
372 /// If the string contains surrogate pairs, they are combined and returned 372 /// If the string contains surrogate pairs, they are combined and returned
373 /// as one integer by this iterator. Unmatched surrogate halves are treated 373 /// as one integer by this iterator. Unmatched surrogate halves are treated
374 /// like valid 16-bit code-units. 374 /// like valid 16-bit code-units.
375 - Runes get runes => value!.runes; 375 + Runes get runes => value.runes;
376 376
377 /// Converts all characters in this string to lower case. 377 /// Converts all characters in this string to lower case.
378 /// If the string is already in all lower case, this method returns `this`. 378 /// If the string is already in all lower case, this method returns `this`.
379 String toLowerCase() { 379 String toLowerCase() {
380 - return value!.toLowerCase(); 380 + return value.toLowerCase();
381 } 381 }
382 382
383 /// Converts all characters in this string to upper case. 383 /// Converts all characters in this string to upper case.
384 /// If the string is already in all upper case, this method returns `this`. 384 /// If the string is already in all upper case, this method returns `this`.
385 String toUpperCase() { 385 String toUpperCase() {
386 - return value!.toUpperCase(); 386 + return value.toUpperCase();
387 } 387 }
388 388
389 @override 389 @override
390 Iterable<Match> allMatches(String string, [int start = 0]) { 390 Iterable<Match> allMatches(String string, [int start = 0]) {
391 - return value!.allMatches(string, start); 391 + return value.allMatches(string, start);
392 } 392 }
393 393
394 @override 394 @override
395 Match? matchAsPrefix(String string, [int start = 0]) { 395 Match? matchAsPrefix(String string, [int start = 0]) {
396 - return value!.matchAsPrefix(string, start); 396 + return value.matchAsPrefix(string, start);
397 } 397 }
398 } 398 }
399 399