Skip to content

Commit

Permalink
v3.0.5
Browse files Browse the repository at this point in the history
- Null safety migration adjustments.
  • Loading branch information
gmpassos committed Mar 11, 2021
1 parent fbfa3fd commit b3da818
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.0.5

- Null safety migration adjustments.

## 3.0.4

- `collections`: improve Null Safety usage.
Expand Down
16 changes: 7 additions & 9 deletions lib/src/collections.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1059,30 +1059,30 @@ Set<T> toNonNullSet<T>(Set? set, {bool forceTypeCast = true}) {
/// Finds in [map] a entry that has one of [keys].
///
/// [ignoreCase] If [true] ignores the case of the keys.
MapEntry<K, V?>? findKeyEntry<K, V>(Map<K?, V?>? map, List<K>? keys,
MapEntry<K, V?>? findKeyEntry<K, V>(Map? map, List<K>? keys,
[bool ignoreCase = false]) {
if (map == null || keys == null || map.isEmpty || keys.isEmpty) return null;

if (ignoreCase) {
for (var key in keys) {
if (map.containsKey(key)) {
var value = map[key];
var value = map[key] as V?;
return MapEntry<K, V?>(key, value);
}

var keyLC = key.toString().toLowerCase();

for (var k in map.keys.whereType<K>()) {
if (k.toString().toLowerCase() == keyLC) {
var value = map[k];
var value = map[k] as V?;
return MapEntry<K, V?>(k, value);
}
}
}
} else {
for (var key in keys) {
if (map.containsKey(key)) {
var value = map[key];
var value = map[key] as V?;
return MapEntry<K, V?>(key, value);
}
}
Expand All @@ -1094,9 +1094,8 @@ MapEntry<K, V?>? findKeyEntry<K, V>(Map<K?, V?>? map, List<K>? keys,
/// Finds in [map] a value that has one of [keys].
///
/// [ignoreCase] If [true] ignores the case of the keys.
V? findKeyValue<K, V>(Map<K?, V?>? map, List<K>? keys,
[bool ignoreCase = false]) {
var entry = findKeyEntry(map, keys, ignoreCase);
V? findKeyValue<K, V>(Map? map, List<K>? keys, [bool ignoreCase = false]) {
var entry = findKeyEntry<K, V>(map, keys, ignoreCase);
return entry != null ? entry.value : null;
}

Expand Down Expand Up @@ -1147,8 +1146,7 @@ V? findKeyPathValue<V>(Map? map, String? keyPath,
/// Finds in [map] a key that has one of [keys].
///
/// [ignoreCase] If [true] ignores the case of the keys.
K? findKeyName<K, V>(Map<K?, V?>? map, List<K>? keys,
[bool ignoreCase = false]) {
K? findKeyName<K, V>(Map? map, List<K>? keys, [bool ignoreCase = false]) {
var entry = findKeyEntry(map, keys, ignoreCase);
return entry != null ? entry.key : null;
}
Expand Down
2 changes: 0 additions & 2 deletions lib/src/resource.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ class ResourceContent {
}

var resolvedURL = resolveUri(url, baseURL: baseURL);
if (content == null) return null;

return ResourceContent.fromURI(resolvedURL, content);
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: swiss_knife
description: Dart Useful Tools - collections, math, date, uri, json, events, resources, regexp, etc...
version: 3.0.4
version: 3.0.5
homepage: https://github.com/gmpassos/swiss_knife

environment:
Expand Down

0 comments on commit b3da818

Please sign in to comment.