Skip to content

Commit

Permalink
Change whereNotNull() to nonNulls.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmpassos committed Jul 12, 2024
1 parent a64dfa3 commit 44583e4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
7 changes: 3 additions & 4 deletions lib/src/bones_ui_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -708,7 +707,7 @@ abstract class UIComponent extends UIEventHandler {
if (ret != null) return [ret];
return _listFieldsEntriesInContentDeepImpl([e]);
})
.whereNotNull()
.nonNulls
.toList();

return fieldsEntries;
Expand Down Expand Up @@ -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));
Expand Down
6 changes: 2 additions & 4 deletions lib/src/bones_ui_test_tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -646,10 +646,8 @@ class UITestContext<U extends UIRoot> {
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]',
Expand Down
3 changes: 1 addition & 2 deletions lib/src/bones_ui_utils.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:collection/collection.dart';
import 'package:dom_builder/dom_builder.dart';

import 'bones_ui_web.dart';
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/component/input_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions lib/src/component/masonry.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -167,7 +166,7 @@ class UIMasonry extends UIComponent {
_computeGCDCache.compute(Parameters2(ns, tolerance));

int _computeGCDImpl(Parameters2<List<int?>, double?> parameters) {
var ns = parameters.a.whereNotNull().toList();
var ns = parameters.a.nonNulls.toList();
var tolerance = parameters.b ?? 0;

if (ns.isEmpty) return 0;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 44583e4

Please sign in to comment.