[various] migrate from ui.hash* to Object.hash* (#1581)
* migrate from ui.hash* to Object.hash*
diff --git a/packages/flutter_image/CHANGELOG.md b/packages/flutter_image/CHANGELOG.md
index 466139a..77ce78e 100644
--- a/packages/flutter_image/CHANGELOG.md
+++ b/packages/flutter_image/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 4.1.2
+
+* Migrates from `ui.hash*` to `Object.hash*`.
+
## 4.1.1
* Updates package description.
diff --git a/packages/flutter_image/lib/network.dart b/packages/flutter_image/lib/network.dart
index b911bde..fc633dd 100644
--- a/packages/flutter_image/lib/network.dart
+++ b/packages/flutter_image/lib/network.dart
@@ -222,7 +222,7 @@
}
@override
- int get hashCode => hashValues(url, scale);
+ int get hashCode => Object.hash(url, scale);
@override
String toString() => '$runtimeType("$url", scale: $scale)';
diff --git a/packages/flutter_image/pubspec.yaml b/packages/flutter_image/pubspec.yaml
index 05cc9a3..99879b7 100644
--- a/packages/flutter_image/pubspec.yaml
+++ b/packages/flutter_image/pubspec.yaml
@@ -3,7 +3,7 @@
Image utilities for Flutter: improved network providers, effects, etc.
repository: https://github.com/flutter/packages/tree/main/packages/flutter_image
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_image%22
-version: 4.1.1
+version: 4.1.2
environment:
sdk: ">=2.12.0 <3.0.0"
diff --git a/packages/flutter_markdown/CHANGELOG.md b/packages/flutter_markdown/CHANGELOG.md
index 0d1e45d..1b31a06 100644
--- a/packages/flutter_markdown/CHANGELOG.md
+++ b/packages/flutter_markdown/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.6.10+2
+
+* Migrates from `ui.hash*` to `Object.hash*`.
+
## 0.6.10+1
* Updates Linux example to remove unneeded library dependencies that
diff --git a/packages/flutter_markdown/lib/src/style_sheet.dart b/packages/flutter_markdown/lib/src/style_sheet.dart
index d25780b..9a7e676 100644
--- a/packages/flutter_markdown/lib/src/style_sheet.dart
+++ b/packages/flutter_markdown/lib/src/style_sheet.dart
@@ -716,7 +716,7 @@
@override
// ignore: avoid_equals_and_hash_code_on_mutable_classes
int get hashCode {
- return hashList(<Object?>[
+ return Object.hashAll(<Object?>[
a,
p,
pPadding,
diff --git a/packages/flutter_markdown/pubspec.yaml b/packages/flutter_markdown/pubspec.yaml
index a675b61..1e8634c 100644
--- a/packages/flutter_markdown/pubspec.yaml
+++ b/packages/flutter_markdown/pubspec.yaml
@@ -4,7 +4,7 @@
formatted with simple Markdown tags.
repository: https://github.com/flutter/packages/tree/main/packages/flutter_markdown
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_markdown%22
-version: 0.6.10+1
+version: 0.6.10+2
environment:
sdk: ">=2.12.0 <3.0.0"
diff --git a/packages/multicast_dns/CHANGELOG.md b/packages/multicast_dns/CHANGELOG.md
index 7331f9b..a20e590 100644
--- a/packages/multicast_dns/CHANGELOG.md
+++ b/packages/multicast_dns/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.3.2+1
+
+* Migrates from `ui.hash*` to `Object.hash*`.
+
## 0.3.2
* Updates package description.
diff --git a/packages/multicast_dns/lib/src/resource_record.dart b/packages/multicast_dns/lib/src/resource_record.dart
index 7f65d98..46e5731 100644
--- a/packages/multicast_dns/lib/src/resource_record.dart
+++ b/packages/multicast_dns/lib/src/resource_record.dart
@@ -10,23 +10,6 @@
import 'package:multicast_dns/src/constants.dart';
import 'package:multicast_dns/src/packet.dart';
-// TODO(dnfield): Probably should go with a real hashing function here
-// when https://github.com/dart-lang/sdk/issues/11617 is figured out.
-const int _seedHashPrime = 2166136261;
-const int _multipleHashPrime = 16777619;
-
-int _combineHash(int current, int hash) =>
- (current & _multipleHashPrime) ^ hash;
-
-int _hashValues(List<int> values) {
- assert(values.isNotEmpty);
-
- return values.fold(
- _seedHashPrime,
- (int current, int next) => _combineHash(current, next),
- );
-}
-
/// Enumeration of support resource record types.
abstract class ResourceRecordType {
// This class is intended to be used as a namespace, and should not be
@@ -171,8 +154,8 @@
}
@override
- int get hashCode => _hashValues(
- <int>[resourceRecordType, fullyQualifiedName.hashCode, questionType]);
+ int get hashCode =>
+ Object.hash(resourceRecordType, fullyQualifiedName, questionType);
@override
bool operator ==(Object other) {
@@ -209,30 +192,16 @@
'$runtimeType{$name, validUntil: ${DateTime.fromMillisecondsSinceEpoch(validUntil)}, $_additionalInfo}';
@override
- bool operator ==(Object other) {
- return other is ResourceRecord && _equals(other);
- }
+ int get hashCode => Object.hash(name, validUntil, resourceRecordType);
- bool _equals(ResourceRecord other) {
- return other.name == name &&
+ @override
+ bool operator ==(Object other) {
+ return other is ResourceRecord &&
+ other.name == name &&
other.validUntil == validUntil &&
other.resourceRecordType == resourceRecordType;
}
- @override
- int get hashCode {
- return _hashValues(<int>[
- name.hashCode,
- validUntil.hashCode,
- resourceRecordType.hashCode,
- _hashCode,
- ]);
- }
-
- // Subclasses of this class should use _hashValues to create a hash code
- // that will then get hashed in with the common values on this class.
- int get _hashCode;
-
/// Low level method for encoding this record into an mDNS packet.
///
/// Subclasses should provide the packet format of their encapsulated data
@@ -257,14 +226,14 @@
String get _additionalInfo => 'domainName: $domainName';
@override
- bool _equals(ResourceRecord other) {
- return other is PtrResourceRecord &&
- other.domainName == domainName &&
- super._equals(other);
- }
+ int get hashCode => Object.hash(domainName.hashCode, super.hashCode);
@override
- int get _hashCode => _combineHash(_seedHashPrime, domainName.hashCode);
+ bool operator ==(Object other) {
+ return super == other &&
+ other is PtrResourceRecord &&
+ other.domainName == domainName;
+ }
@override
Uint8List encodeResponseRecord() {
@@ -293,12 +262,14 @@
String get _additionalInfo => 'address: $address';
@override
- bool _equals(ResourceRecord other) {
- return other is IPAddressResourceRecord && other.address == address;
- }
+ int get hashCode => Object.hash(address.hashCode, super.hashCode);
@override
- int get _hashCode => _combineHash(_seedHashPrime, address.hashCode);
+ bool operator ==(Object other) {
+ return super == other &&
+ other is IPAddressResourceRecord &&
+ other.address == address;
+ }
@override
Uint8List encodeResponseRecord() {
@@ -335,8 +306,13 @@
'target: $target, port: $port, priority: $priority, weight: $weight';
@override
- bool _equals(ResourceRecord other) {
- return other is SrvResourceRecord &&
+ int get hashCode =>
+ Object.hash(target, port, priority, weight, super.hashCode);
+
+ @override
+ bool operator ==(Object other) {
+ return super == other &&
+ other is SrvResourceRecord &&
other.target == target &&
other.port == port &&
other.priority == priority &&
@@ -344,14 +320,6 @@
}
@override
- int get _hashCode => _hashValues(<int>[
- target.hashCode,
- port.hashCode,
- priority.hashCode,
- weight.hashCode,
- ]);
-
- @override
Uint8List encodeResponseRecord() {
final List<int> data = utf8.encode(target);
final Uint8List result = Uint8List(data.length + 7);
@@ -380,12 +348,11 @@
String get _additionalInfo => 'text: $text';
@override
- bool _equals(ResourceRecord other) {
- return other is TxtResourceRecord && other.text == text;
- }
+ int get hashCode => Object.hash(text.hashCode, super.hashCode);
@override
- int get _hashCode => _combineHash(_seedHashPrime, text.hashCode);
+ bool operator ==(Object other) =>
+ super == other && other is TxtResourceRecord && other.text == text;
@override
Uint8List encodeResponseRecord() {
diff --git a/packages/multicast_dns/pubspec.yaml b/packages/multicast_dns/pubspec.yaml
index 00a6a61..c43df34 100644
--- a/packages/multicast_dns/pubspec.yaml
+++ b/packages/multicast_dns/pubspec.yaml
@@ -2,10 +2,10 @@
description: Dart package for performing mDNS queries (e.g. Bonjour, Avahi).
repository: https://github.com/flutter/packages/tree/main/packages/multicast_dns
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+multicast_dns%22
-version: 0.3.2
+version: 0.3.2+1
environment:
- sdk: ">=2.12.0 <3.0.0"
+ sdk: ">=2.14.0 <3.0.0"
dependencies:
meta: ^1.3.0
diff --git a/packages/multicast_dns/test/decode_test.dart b/packages/multicast_dns/test/decode_test.dart
index c828dae..442d599 100644
--- a/packages/multicast_dns/test/decode_test.dart
+++ b/packages/multicast_dns/test/decode_test.dart
@@ -158,7 +158,7 @@
domainName: '______________________._______________.____._____',
),
TxtResourceRecord(
- '_______________.____._____',
+ '______________________.____________.____._____',
result[1].validUntil,
text: 'model=MacBookPro14,3\nosxvers=18\necolor=225,225,223\n',
),
@@ -176,7 +176,7 @@
domainName: '______________________._______________.____._____',
),
TxtResourceRecord(
- '_______________.____._____',
+ '______________________.____________.____._____',
result[1].validUntil,
text: (')' * 129) + '\n',
),
diff --git a/packages/palette_generator/CHANGELOG.md b/packages/palette_generator/CHANGELOG.md
index fa1c790..3dd0f60 100644
--- a/packages/palette_generator/CHANGELOG.md
+++ b/packages/palette_generator/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.3.3+1
+
+* Migrates from `ui.hash*` to `Object.hash*`.
+
## 0.3.3
* Avoids dynamic calls in equality checks.
diff --git a/packages/palette_generator/lib/palette_generator.dart b/packages/palette_generator/lib/palette_generator.dart
index e155d2b..1205c88 100644
--- a/packages/palette_generator/lib/palette_generator.dart
+++ b/packages/palette_generator/lib/palette_generator.dart
@@ -634,7 +634,7 @@
@override
int get hashCode {
- return hashValues(
+ return Object.hash(
minimumSaturation,
targetSaturation,
maximumSaturation,
@@ -852,9 +852,7 @@
}
@override
- int get hashCode {
- return hashValues(color, population);
- }
+ int get hashCode => Object.hash(color, population);
@override
bool operator ==(Object other) {
diff --git a/packages/palette_generator/pubspec.yaml b/packages/palette_generator/pubspec.yaml
index bd3d2e0..cadb365 100644
--- a/packages/palette_generator/pubspec.yaml
+++ b/packages/palette_generator/pubspec.yaml
@@ -2,11 +2,11 @@
description: Flutter package for generating palette colors from a source image.
repository: https://github.com/flutter/packages/tree/main/packages/palette_generator
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+palette_generator%22
-version: 0.3.3
+version: 0.3.3+1
environment:
- sdk: ">=2.12.0 <3.0.0"
- flutter: ">=1.15.21"
+ sdk: ">=2.14.0 <3.0.0"
+ flutter: ">=3.0.0"
dependencies:
collection: ^1.15.0
diff --git a/packages/rfw/CHANGELOG.md b/packages/rfw/CHANGELOG.md
index 3b97c65..2bb4c87 100644
--- a/packages/rfw/CHANGELOG.md
+++ b/packages/rfw/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 1.0.4
+
+* Migrates from `ui.hash*` to `Object.hash*`.
+
## 1.0.3
* Transitions internal testing from a command line lcov tool to a
diff --git a/packages/rfw/lib/src/flutter/runtime.dart b/packages/rfw/lib/src/flutter/runtime.dart
index 7a989c6..8255d3a 100644
--- a/packages/rfw/lib/src/flutter/runtime.dart
+++ b/packages/rfw/lib/src/flutter/runtime.dart
@@ -1075,7 +1075,7 @@
}
@override
- int get hashCode => hashValues(section, hashList(parts));
+ int get hashCode => Object.hash(section, Object.hashAll(parts));
}
class _Subscription {
diff --git a/packages/rfw/pubspec.yaml b/packages/rfw/pubspec.yaml
index 8865604..a70bdbc 100644
--- a/packages/rfw/pubspec.yaml
+++ b/packages/rfw/pubspec.yaml
@@ -2,7 +2,7 @@
description: "Remote Flutter widgets: a library for rendering declarative widget description files at runtime."
repository: https://github.com/flutter/packages/tree/main/packages/rfw
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+rfw%22
-version: 1.0.3
+version: 1.0.4
environment:
sdk: ">=2.13.0 <3.0.0"