From b3da818d583e3de4917eeffe6ac6dc549f3db5b4 Mon Sep 17 00:00:00 2001 From: gmpassos Date: Wed, 10 Mar 2021 22:35:18 -0300 Subject: [PATCH] v3.0.5 - Null safety migration adjustments. --- CHANGELOG.md | 4 ++++ lib/src/collections.dart | 16 +++++++--------- lib/src/resource.dart | 2 -- pubspec.yaml | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebb4078..52ddb14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.0.5 + +- Null safety migration adjustments. + ## 3.0.4 - `collections`: improve Null Safety usage. diff --git a/lib/src/collections.dart b/lib/src/collections.dart index b8a9580..475ba30 100644 --- a/lib/src/collections.dart +++ b/lib/src/collections.dart @@ -1059,14 +1059,14 @@ Set toNonNullSet(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? findKeyEntry(Map? map, List? keys, +MapEntry? findKeyEntry(Map? map, List? 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(key, value); } @@ -1074,7 +1074,7 @@ MapEntry? findKeyEntry(Map? map, List? keys, for (var k in map.keys.whereType()) { if (k.toString().toLowerCase() == keyLC) { - var value = map[k]; + var value = map[k] as V?; return MapEntry(k, value); } } @@ -1082,7 +1082,7 @@ MapEntry? findKeyEntry(Map? map, List? keys, } else { for (var key in keys) { if (map.containsKey(key)) { - var value = map[key]; + var value = map[key] as V?; return MapEntry(key, value); } } @@ -1094,9 +1094,8 @@ MapEntry? findKeyEntry(Map? map, List? keys, /// Finds in [map] a value that has one of [keys]. /// /// [ignoreCase] If [true] ignores the case of the keys. -V? findKeyValue(Map? map, List? keys, - [bool ignoreCase = false]) { - var entry = findKeyEntry(map, keys, ignoreCase); +V? findKeyValue(Map? map, List? keys, [bool ignoreCase = false]) { + var entry = findKeyEntry(map, keys, ignoreCase); return entry != null ? entry.value : null; } @@ -1147,8 +1146,7 @@ V? findKeyPathValue(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(Map? map, List? keys, - [bool ignoreCase = false]) { +K? findKeyName(Map? map, List? keys, [bool ignoreCase = false]) { var entry = findKeyEntry(map, keys, ignoreCase); return entry != null ? entry.key : null; } diff --git a/lib/src/resource.dart b/lib/src/resource.dart index a28c64b..d714197 100644 --- a/lib/src/resource.dart +++ b/lib/src/resource.dart @@ -143,8 +143,6 @@ class ResourceContent { } var resolvedURL = resolveUri(url, baseURL: baseURL); - if (content == null) return null; - return ResourceContent.fromURI(resolvedURL, content); } diff --git a/pubspec.yaml b/pubspec.yaml index 0ad8ab6..f512fe7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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: