diff --git a/CHANGELOG.md b/CHANGELOG.md index 8426b91..5bc4574 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 3.1.3 + +- Code adjustments for `lints: ^2.0.1`. +- intl: ^0.18.0 +- resource_portable: ^3.0.1 +- lints: ^2.0.1 +- test: ^1.22.1 + ## 3.1.2 - `DataURLBase64`: diff --git a/README.md b/README.md index 6e1afe3..1b258fa 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![pub package](https://img.shields.io/pub/v/swiss_knife.svg?logo=dart&logoColor=00b9fc)](https://pub.dartlang.org/packages/swiss_knife) [![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety) -[![CI](https://img.shields.io/github/workflow/status/gmpassos/swiss_knife/Dart%20CI/master?logo=github-actions&logoColor=white)](https://github.com/gmpassos/swiss_knife/actions) +[![Dart CI](https://github.com/gmpassos/swiss_knife/actions/workflows/dart.yml/badge.svg?branch=master)](https://github.com/gmpassos/swiss_knife/actions/workflows/dart.yml) [![GitHub Tag](https://img.shields.io/github/v/tag/gmpassos/swiss_knife?logo=git&logoColor=white)](https://github.com/gmpassos/swiss_knife/releases) [![New Commits](https://img.shields.io/github/commits-since/gmpassos/swiss_knife/latest?logo=git&logoColor=white)](https://github.com/gmpassos/swiss_knife/network) [![Last Commits](https://img.shields.io/github/last-commit/gmpassos/swiss_knife?logo=git&logoColor=white)](https://github.com/gmpassos/swiss_knife/commits/master) diff --git a/lib/src/collections.dart b/lib/src/collections.dart index a9f3604..a4268c7 100644 --- a/lib/src/collections.dart +++ b/lib/src/collections.dart @@ -1466,7 +1466,7 @@ Map? deepCopyMap(Map? map, {Copier? copier}) { if (map == null) return null; if (map.isEmpty) return {}; return map.map((K k, V v) => MapEntry( - deepCopy(k, copier: copier)!, deepCopy(v, copier: copier)!)); + deepCopy(k, copier: copier) as K, deepCopy(v, copier: copier) as V)); } typedef ValueFilter = bool Function( @@ -2802,8 +2802,7 @@ class TreeReferenceMap implements Map { /// Walks tree from [root] and stops when [walker] returns some [R] object. R? walkTree(R Function(K node) walker, {K? root}) { - root ??= this.root; - return _walkTreeImpl(root!, walker); + return _walkTreeImpl(root ?? this.root, walker); } R? _walkTreeImpl(K node, R Function(K node) walker) { diff --git a/lib/src/data.dart b/lib/src/data.dart index 8c779eb..58e92e6 100644 --- a/lib/src/data.dart +++ b/lib/src/data.dart @@ -673,7 +673,7 @@ class Geolocation { } static String formatGeolocation(Point geo) { - return formatLatitude(geo.x) + ' ' + formatLongitude(geo.y); + return '${formatLatitude(geo.x)} ${formatLongitude(geo.y)}'; } final num _latitude; @@ -851,9 +851,9 @@ String? dataSizeFormat(int? size, {bool? decimalBase, bool? binaryBase}) { var s = '${size ~/ 1000} KB'; return s; } else if (size < 1000 * 1000 * 1000) { - return formatDecimal(size / (1000 * 1000))! + ' MB'; + return '${formatDecimal(size / (1000 * 1000))!} MB'; } else { - return formatDecimal(size / (1000 * 1000 * 1000))! + ' GB'; + return '${formatDecimal(size / (1000 * 1000 * 1000))!} GB'; } } else { if (size < 1024) { @@ -862,9 +862,9 @@ String? dataSizeFormat(int? size, {bool? decimalBase, bool? binaryBase}) { var s = '${size ~/ 1024} KiB'; return s; } else if (size < 1024 * 1024 * 1024) { - return formatDecimal(size / (1024 * 1024))! + ' MiB'; + return '${formatDecimal(size / (1024 * 1024))!} MiB'; } else { - return formatDecimal(size / (1024 * 1024 * 1024))! + ' GiB'; + return '${formatDecimal(size / (1024 * 1024 * 1024))!} GiB'; } } } diff --git a/lib/src/events.dart b/lib/src/events.dart index f93beee..ff1764b 100644 --- a/lib/src/events.dart +++ b/lib/src/events.dart @@ -1308,7 +1308,7 @@ class UniqueCaller { stackTraceIdentifier?.toString() ?? UniqueCaller.stackTraceIdentifier()); - _IdentifierWrapper get identifier => _identifier; + Object get identifier => _identifier; static final Set<_IdentifierWrapper> _calling = {}; diff --git a/lib/src/math.dart b/lib/src/math.dart index d691018..f1dc0e1 100644 --- a/lib/src/math.dart +++ b/lib/src/math.dart @@ -747,7 +747,11 @@ class Scale { // ignore: empty_catches catch (ignore) {} - _length = length!; + if (length == null) { + throw StateError("Can't compute scale length!"); + } + + _length = length; } static Scale? from(Iterable? list) { diff --git a/lib/src/resource.dart b/lib/src/resource.dart index 8482b92..5b5056d 100644 --- a/lib/src/resource.dart +++ b/lib/src/resource.dart @@ -268,7 +268,7 @@ class ResourceContent { var uri = reference != null ? await reference.uriResolved : null; uri ??= await ResourceContent.fromURI('./')!.uriResolved; - var uriPath = Uri.decodeComponent(uri!.path) + '/'; + var uriPath = '${Uri.decodeComponent(uri!.path)}/'; var uriPathParts = uriPath.split('/'); if (uriPath.endsWith('/')) uriPathParts.removeLast(); diff --git a/lib/src/uri.dart b/lib/src/uri.dart index 7ab1f73..6515c29 100644 --- a/lib/src/uri.dart +++ b/lib/src/uri.dart @@ -55,10 +55,7 @@ String getUriBaseHostAndPort({bool suppressPort80 = true, int? port}) { /// Returns base Uri as URL string. String getUriRootURL({bool suppressPort80 = true, int? port}) { - return getUriBaseScheme() + - '://' + - getUriBaseHostAndPort(suppressPort80: suppressPort80, port: port) + - '/'; + return '${getUriBaseScheme()}://${getUriBaseHostAndPort(suppressPort80: suppressPort80, port: port)}/'; } /// Builds an Uri with the parameters. @@ -97,7 +94,7 @@ Uri buildUri(String? scheme, String? host, int? port, if (fragment == null) { fragment = pathFragment; } else { - fragment = pathFragment + '&' + fragment; + fragment = '$pathFragment&$fragment'; } fragmentFromPath = true; @@ -118,7 +115,7 @@ Uri buildUri(String? scheme, String? host, int? port, if (queryString == null) { queryString = pathQuery; } else { - queryString = pathQuery + '&' + queryString; + queryString = '$pathQuery&$queryString'; } queryStringFromPath = true; @@ -144,7 +141,7 @@ Uri buildUri(String? scheme, String? host, int? port, if (fragmentFromPath) { fragment = path2Fragment; } else { - fragment = path2Fragment + '&' + fragment; + fragment = '$path2Fragment&$fragment'; } } @@ -172,7 +169,7 @@ Uri buildUri(String? scheme, String? host, int? port, if (queryStringFromPath) { queryString = path2Query; } else { - queryString = path2Query + '&' + queryString; + queryString = '$path2Query&$queryString'; } } diff --git a/lib/src/utils.dart b/lib/src/utils.dart index ee9817c..8d2df41 100644 --- a/lib/src/utils.dart +++ b/lib/src/utils.dart @@ -20,7 +20,7 @@ String encodeQueryString(Map? parameters) { parameters.forEach((key, value) { var pair = - Uri.encodeQueryComponent(key) + '=' + Uri.encodeQueryComponent(value); + '${Uri.encodeQueryComponent(key)}=${Uri.encodeQueryComponent(value)}'; pairs.add(pair); }); diff --git a/pubspec.yaml b/pubspec.yaml index 55415a9..24e6a89 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,18 +1,18 @@ name: swiss_knife description: Dart Useful Tools - collections, math, date, uri, json, events, resources, regexp, etc... -version: 3.1.2 +version: 3.1.3 homepage: https://github.com/gmpassos/swiss_knife environment: sdk: '>=2.12.0 <3.0.0' dependencies: - intl: ^0.17.0 - resource_portable: ^3.0.0 + intl: ^0.18.0 + resource_portable: ^3.0.1 dev_dependencies: - lints: ^1.0.1 - test: ^1.17.12 + lints: ^2.0.1 + test: ^1.22.1 dependency_validator: ^3.2.2 collection: ^1.17.0 coverage: ^1.6.1