[various] migrate from ui.hash* to Object.hash* (#1581)

* migrate from ui.hash* to Object.hash*
This commit is contained in:
Viren Khatri
2022-05-31 21:19:10 +05:30
committed by GitHub
parent 3b75442b30
commit 0f1af1daa8
16 changed files with 64 additions and 79 deletions

View File

@ -1,3 +1,7 @@
## 4.1.2
* Migrates from `ui.hash*` to `Object.hash*`.
## 4.1.1 ## 4.1.1
* Updates package description. * Updates package description.

View File

@ -222,7 +222,7 @@ class NetworkImageWithRetry extends ImageProvider<NetworkImageWithRetry> {
} }
@override @override
int get hashCode => hashValues(url, scale); int get hashCode => Object.hash(url, scale);
@override @override
String toString() => '$runtimeType("$url", scale: $scale)'; String toString() => '$runtimeType("$url", scale: $scale)';

View File

@ -3,7 +3,7 @@ description: >
Image utilities for Flutter: improved network providers, effects, etc. Image utilities for Flutter: improved network providers, effects, etc.
repository: https://github.com/flutter/packages/tree/main/packages/flutter_image 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 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: environment:
sdk: ">=2.12.0 <3.0.0" sdk: ">=2.12.0 <3.0.0"

View File

@ -1,3 +1,7 @@
## 0.6.10+2
* Migrates from `ui.hash*` to `Object.hash*`.
## 0.6.10+1 ## 0.6.10+1
* Updates Linux example to remove unneeded library dependencies that * Updates Linux example to remove unneeded library dependencies that

View File

@ -716,7 +716,7 @@ class MarkdownStyleSheet {
@override @override
// ignore: avoid_equals_and_hash_code_on_mutable_classes // ignore: avoid_equals_and_hash_code_on_mutable_classes
int get hashCode { int get hashCode {
return hashList(<Object?>[ return Object.hashAll(<Object?>[
a, a,
p, p,
pPadding, pPadding,

View File

@ -4,7 +4,7 @@ description: A Markdown renderer for Flutter. Create rich text output,
formatted with simple Markdown tags. formatted with simple Markdown tags.
repository: https://github.com/flutter/packages/tree/main/packages/flutter_markdown 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 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: environment:
sdk: ">=2.12.0 <3.0.0" sdk: ">=2.12.0 <3.0.0"

View File

@ -1,3 +1,7 @@
## 0.3.2+1
* Migrates from `ui.hash*` to `Object.hash*`.
## 0.3.2 ## 0.3.2
* Updates package description. * Updates package description.

View File

@ -10,23 +10,6 @@ import 'package:meta/meta.dart';
import 'package:multicast_dns/src/constants.dart'; import 'package:multicast_dns/src/constants.dart';
import 'package:multicast_dns/src/packet.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. /// Enumeration of support resource record types.
abstract class ResourceRecordType { abstract class ResourceRecordType {
// This class is intended to be used as a namespace, and should not be // This class is intended to be used as a namespace, and should not be
@ -171,8 +154,8 @@ class ResourceRecordQuery {
} }
@override @override
int get hashCode => _hashValues( int get hashCode =>
<int>[resourceRecordType, fullyQualifiedName.hashCode, questionType]); Object.hash(resourceRecordType, fullyQualifiedName, questionType);
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
@ -209,30 +192,16 @@ abstract class ResourceRecord {
'$runtimeType{$name, validUntil: ${DateTime.fromMillisecondsSinceEpoch(validUntil)}, $_additionalInfo}'; '$runtimeType{$name, validUntil: ${DateTime.fromMillisecondsSinceEpoch(validUntil)}, $_additionalInfo}';
@override @override
bool operator ==(Object other) { int get hashCode => Object.hash(name, validUntil, resourceRecordType);
return other is ResourceRecord && _equals(other);
}
bool _equals(ResourceRecord other) { @override
return other.name == name && bool operator ==(Object other) {
return other is ResourceRecord &&
other.name == name &&
other.validUntil == validUntil && other.validUntil == validUntil &&
other.resourceRecordType == resourceRecordType; 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. /// Low level method for encoding this record into an mDNS packet.
/// ///
/// Subclasses should provide the packet format of their encapsulated data /// Subclasses should provide the packet format of their encapsulated data
@ -257,14 +226,14 @@ class PtrResourceRecord extends ResourceRecord {
String get _additionalInfo => 'domainName: $domainName'; String get _additionalInfo => 'domainName: $domainName';
@override @override
bool _equals(ResourceRecord other) { int get hashCode => Object.hash(domainName.hashCode, super.hashCode);
return other is PtrResourceRecord &&
other.domainName == domainName &&
super._equals(other);
}
@override @override
int get _hashCode => _combineHash(_seedHashPrime, domainName.hashCode); bool operator ==(Object other) {
return super == other &&
other is PtrResourceRecord &&
other.domainName == domainName;
}
@override @override
Uint8List encodeResponseRecord() { Uint8List encodeResponseRecord() {
@ -293,12 +262,14 @@ class IPAddressResourceRecord extends ResourceRecord {
String get _additionalInfo => 'address: $address'; String get _additionalInfo => 'address: $address';
@override @override
bool _equals(ResourceRecord other) { int get hashCode => Object.hash(address.hashCode, super.hashCode);
return other is IPAddressResourceRecord && other.address == address;
}
@override @override
int get _hashCode => _combineHash(_seedHashPrime, address.hashCode); bool operator ==(Object other) {
return super == other &&
other is IPAddressResourceRecord &&
other.address == address;
}
@override @override
Uint8List encodeResponseRecord() { Uint8List encodeResponseRecord() {
@ -335,22 +306,19 @@ class SrvResourceRecord extends ResourceRecord {
'target: $target, port: $port, priority: $priority, weight: $weight'; 'target: $target, port: $port, priority: $priority, weight: $weight';
@override @override
bool _equals(ResourceRecord other) { int get hashCode =>
return other is SrvResourceRecord && Object.hash(target, port, priority, weight, super.hashCode);
@override
bool operator ==(Object other) {
return super == other &&
other is SrvResourceRecord &&
other.target == target && other.target == target &&
other.port == port && other.port == port &&
other.priority == priority && other.priority == priority &&
other.weight == weight; other.weight == weight;
} }
@override
int get _hashCode => _hashValues(<int>[
target.hashCode,
port.hashCode,
priority.hashCode,
weight.hashCode,
]);
@override @override
Uint8List encodeResponseRecord() { Uint8List encodeResponseRecord() {
final List<int> data = utf8.encode(target); final List<int> data = utf8.encode(target);
@ -380,12 +348,11 @@ class TxtResourceRecord extends ResourceRecord {
String get _additionalInfo => 'text: $text'; String get _additionalInfo => 'text: $text';
@override @override
bool _equals(ResourceRecord other) { int get hashCode => Object.hash(text.hashCode, super.hashCode);
return other is TxtResourceRecord && other.text == text;
}
@override @override
int get _hashCode => _combineHash(_seedHashPrime, text.hashCode); bool operator ==(Object other) =>
super == other && other is TxtResourceRecord && other.text == text;
@override @override
Uint8List encodeResponseRecord() { Uint8List encodeResponseRecord() {

View File

@ -2,10 +2,10 @@ name: multicast_dns
description: Dart package for performing mDNS queries (e.g. Bonjour, Avahi). description: Dart package for performing mDNS queries (e.g. Bonjour, Avahi).
repository: https://github.com/flutter/packages/tree/main/packages/multicast_dns 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 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: environment:
sdk: ">=2.12.0 <3.0.0" sdk: ">=2.14.0 <3.0.0"
dependencies: dependencies:
meta: ^1.3.0 meta: ^1.3.0

View File

@ -158,7 +158,7 @@ void testValidPackages() {
domainName: '______________________._______________.____._____', domainName: '______________________._______________.____._____',
), ),
TxtResourceRecord( TxtResourceRecord(
'_______________.____._____', '______________________.____________.____._____',
result[1].validUntil, result[1].validUntil,
text: 'model=MacBookPro14,3\nosxvers=18\necolor=225,225,223\n', text: 'model=MacBookPro14,3\nosxvers=18\necolor=225,225,223\n',
), ),
@ -176,7 +176,7 @@ void testValidPackages() {
domainName: '______________________._______________.____._____', domainName: '______________________._______________.____._____',
), ),
TxtResourceRecord( TxtResourceRecord(
'_______________.____._____', '______________________.____________.____._____',
result[1].validUntil, result[1].validUntil,
text: (')' * 129) + '\n', text: (')' * 129) + '\n',
), ),

View File

@ -1,3 +1,7 @@
## 0.3.3+1
* Migrates from `ui.hash*` to `Object.hash*`.
## 0.3.3 ## 0.3.3
* Avoids dynamic calls in equality checks. * Avoids dynamic calls in equality checks.

View File

@ -634,7 +634,7 @@ class PaletteTarget with Diagnosticable {
@override @override
int get hashCode { int get hashCode {
return hashValues( return Object.hash(
minimumSaturation, minimumSaturation,
targetSaturation, targetSaturation,
maximumSaturation, maximumSaturation,
@ -852,9 +852,7 @@ class PaletteColor with Diagnosticable {
} }
@override @override
int get hashCode { int get hashCode => Object.hash(color, population);
return hashValues(color, population);
}
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {

View File

@ -2,11 +2,11 @@ name: palette_generator
description: Flutter package for generating palette colors from a source image. description: Flutter package for generating palette colors from a source image.
repository: https://github.com/flutter/packages/tree/main/packages/palette_generator 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 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: environment:
sdk: ">=2.12.0 <3.0.0" sdk: ">=2.14.0 <3.0.0"
flutter: ">=1.15.21" flutter: ">=3.0.0"
dependencies: dependencies:
collection: ^1.15.0 collection: ^1.15.0

View File

@ -1,3 +1,7 @@
## 1.0.4
* Migrates from `ui.hash*` to `Object.hash*`.
## 1.0.3 ## 1.0.3
* Transitions internal testing from a command line lcov tool to a * Transitions internal testing from a command line lcov tool to a

View File

@ -1075,7 +1075,7 @@ class _Key {
} }
@override @override
int get hashCode => hashValues(section, hashList(parts)); int get hashCode => Object.hash(section, Object.hashAll(parts));
} }
class _Subscription { class _Subscription {

View File

@ -2,7 +2,7 @@ name: rfw
description: "Remote Flutter widgets: a library for rendering declarative widget description files at runtime." description: "Remote Flutter widgets: a library for rendering declarative widget description files at runtime."
repository: https://github.com/flutter/packages/tree/main/packages/rfw 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 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: environment:
sdk: ">=2.13.0 <3.0.0" sdk: ">=2.13.0 <3.0.0"