From 44583e4bfe9191048cd0b0cfebe397203140969b Mon Sep 17 00:00:00 2001 From: gmpassos Date: Fri, 12 Jul 2024 00:10:20 -0300 Subject: [PATCH] Change `whereNotNull()` to `nonNulls`. --- lib/src/bones_ui_component.dart | 7 +++---- lib/src/bones_ui_test_tools.dart | 6 ++---- lib/src/bones_ui_utils.dart | 3 +-- lib/src/component/input_config.dart | 2 +- lib/src/component/masonry.dart | 7 +++---- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/lib/src/bones_ui_component.dart b/lib/src/bones_ui_component.dart index bd43872..4c2a575 100644 --- a/lib/src/bones_ui_component.dart +++ b/lib/src/bones_ui_component.dart @@ -2,8 +2,7 @@ import 'dart:async'; import 'dart:collection'; import 'package:bones_ui/src/bones_ui_utils.dart'; -import 'package:collection/collection.dart' - show IterableExtension, IterableNullableExtension; +import 'package:collection/collection.dart' show IterableExtension; import 'package:dom_builder/dom_builder.dart'; import 'package:dom_tools/dom_tools.dart'; import 'package:dynamic_call/dynamic_call.dart'; @@ -708,7 +707,7 @@ abstract class UIComponent extends UIEventHandler { if (ret != null) return [ret]; return _listFieldsEntriesInContentDeepImpl([e]); }) - .whereNotNull() + .nonNulls .toList(); return fieldsEntries; @@ -2614,7 +2613,7 @@ abstract class UIComponent extends UIEventHandler { var k = keyAs!(key); var v = valueAs!(value); return k != null ? MapEntry(k, v) : null; - }).whereNotNull(); + }).nonNulls; if (filter != null) { entries = entries.where((e) => filter(e.key, e.value)); diff --git a/lib/src/bones_ui_test_tools.dart b/lib/src/bones_ui_test_tools.dart index d7cd1bb..3257210 100644 --- a/lib/src/bones_ui_test_tools.dart +++ b/lib/src/bones_ui_test_tools.dart @@ -646,10 +646,8 @@ class UITestContext { var uiName = isInitialized ? uiRoot.name : null; uiName = cleanText(uiName); - var prefix = [uiName, testName] - .whereNotNull() - .where((e) => e.isNotEmpty) - .join(' - '); + var prefix = + [uiName, testName].nonNulls.where((e) => e.isNotEmpty).join(' - '); var parts = [ if (prefix.isNotEmpty) '[$prefix]', diff --git a/lib/src/bones_ui_utils.dart b/lib/src/bones_ui_utils.dart index 611c738..4f6d69b 100644 --- a/lib/src/bones_ui_utils.dart +++ b/lib/src/bones_ui_utils.dart @@ -1,4 +1,3 @@ -import 'package:collection/collection.dart'; import 'package:dom_builder/dom_builder.dart'; import 'bones_ui_web.dart'; @@ -41,7 +40,7 @@ String? resolveToText(Object? o) { if (o is String) { return o; } else if (o is Iterable) { - var l = o.whereNotNull().map(resolveToText).whereNotNull().toList(); + var l = o.nonNulls.map(resolveToText).nonNulls.toList(); return l.isEmpty ? null : l.join(); } else if (o is UIElement) { return o.text; diff --git a/lib/src/component/input_config.dart b/lib/src/component/input_config.dart index 055a8d2..5928c29 100644 --- a/lib/src/component/input_config.dart +++ b/lib/src/component/input_config.dart @@ -818,7 +818,7 @@ class UIInputTable extends UIComponent { if (nodes == null) return null; - nodes = nodes.whereNotNull().toList(); + nodes = nodes.nonNulls.toList(); if (nodes.isEmpty) return null; TABLEElement? table; diff --git a/lib/src/component/masonry.dart b/lib/src/component/masonry.dart index c8df583..c411b23 100644 --- a/lib/src/component/masonry.dart +++ b/lib/src/component/masonry.dart @@ -1,7 +1,6 @@ import 'dart:html'; -import 'package:collection/collection.dart' - show IterableExtension, IterableNullableExtension; +import 'package:collection/collection.dart' show IterableExtension; import 'package:dom_builder/dom_builder.dart'; import 'package:dom_tools/dom_tools.dart'; import 'package:swiss_knife/swiss_knife.dart'; @@ -167,7 +166,7 @@ class UIMasonry extends UIComponent { _computeGCDCache.compute(Parameters2(ns, tolerance)); int _computeGCDImpl(Parameters2, double?> parameters) { - var ns = parameters.a.whereNotNull().toList(); + var ns = parameters.a.nonNulls.toList(); var tolerance = parameters.b ?? 0; if (ns.isEmpty) return 0; @@ -230,7 +229,7 @@ class UIMasonry extends UIComponent { var n = dimensionGetter(item); dimension.add(n); } - var list = dimension.whereNotNull().where((n) => n >= 10).toList(); + var list = dimension.nonNulls.where((n) => n >= 10).toList(); list.sort(); return list; }