From 671aa9e95e979f09318cf34a8637733a6eccba79 Mon Sep 17 00:00:00 2001 From: Viren Khatri <44755140+werainkhatri@users.noreply.github.com> Date: Sat, 5 Mar 2022 02:26:21 +0530 Subject: [PATCH] complete migration of flutter repo to Object.hash* (#99505) --- .../demo/transformations/transformations_demo_board.dart | 2 +- .../flutter_gallery/lib/gallery/demo.dart | 2 +- .../flutter_gallery/lib/gallery/demos.dart | 2 +- .../flutter_gallery/lib/gallery/options.dart | 2 +- .../flutter_gallery/lib/gallery/scales.dart | 4 ++-- dev/integration_tests/web/lib/stack_trace.dart | 9 ++++----- .../api/lib/material/autocomplete/autocomplete.1.dart | 2 +- .../api/lib/widgets/autocomplete/raw_autocomplete.1.dart | 2 +- packages/flutter/lib/src/foundation/README.md | 6 +++--- .../flutter/lib/src/material/expansion_tile_theme.dart | 2 +- packages/flutter/lib/src/painting/basic_types.dart | 3 ++- packages/flutter/lib/src/widgets/shortcuts.dart | 2 +- packages/flutter/test/material/animated_icons_test.dart | 2 +- packages/flutter_goldens/test/flutter_goldens_test.dart | 3 +-- packages/flutter_test/lib/src/image.dart | 4 +--- packages/flutter_test/lib/src/window.dart | 2 +- packages/flutter_test/test/matchers_test.dart | 2 +- .../flutter_tools/lib/src/commands/update_packages.dart | 2 +- 18 files changed, 25 insertions(+), 28 deletions(-) diff --git a/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_board.dart b/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_board.dart index 309f950210..c1e02bef5e 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_board.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_board.dart @@ -275,7 +275,7 @@ class BoardPoint { } @override - int get hashCode => hashValues(q, r); + int get hashCode => Object.hash(q, r); BoardPoint copyWithColor(Color nextColor) => BoardPoint(q, r, color: nextColor); diff --git a/dev/integration_tests/flutter_gallery/lib/gallery/demo.dart b/dev/integration_tests/flutter_gallery/lib/gallery/demo.dart index aca417223f..5e6d449c80 100644 --- a/dev/integration_tests/flutter_gallery/lib/gallery/demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/gallery/demo.dart @@ -37,7 +37,7 @@ class ComponentDemoTabData { } @override - int get hashCode => hashValues(tabName, description, documentationUrl); + int get hashCode => Object.hash(tabName, description, documentationUrl); } class TabbedComponentDemoScaffold extends StatelessWidget { diff --git a/dev/integration_tests/flutter_gallery/lib/gallery/demos.dart b/dev/integration_tests/flutter_gallery/lib/gallery/demos.dart index bf2dbadbd3..13af7693c3 100644 --- a/dev/integration_tests/flutter_gallery/lib/gallery/demos.dart +++ b/dev/integration_tests/flutter_gallery/lib/gallery/demos.dart @@ -29,7 +29,7 @@ class GalleryDemoCategory { } @override - int get hashCode => hashValues(name, icon); + int get hashCode => Object.hash(name, icon); @override String toString() { diff --git a/dev/integration_tests/flutter_gallery/lib/gallery/options.dart b/dev/integration_tests/flutter_gallery/lib/gallery/options.dart index 389caeb004..0c96fdc080 100644 --- a/dev/integration_tests/flutter_gallery/lib/gallery/options.dart +++ b/dev/integration_tests/flutter_gallery/lib/gallery/options.dart @@ -71,7 +71,7 @@ class GalleryOptions { } @override - int get hashCode => hashValues( + int get hashCode => Object.hash( themeMode, textScaleFactor, visualDensity, diff --git a/dev/integration_tests/flutter_gallery/lib/gallery/scales.dart b/dev/integration_tests/flutter_gallery/lib/gallery/scales.dart index 12549cb53b..09c490932a 100644 --- a/dev/integration_tests/flutter_gallery/lib/gallery/scales.dart +++ b/dev/integration_tests/flutter_gallery/lib/gallery/scales.dart @@ -21,7 +21,7 @@ class GalleryTextScaleValue { } @override - int get hashCode => hashValues(scale, label); + int get hashCode => Object.hash(scale, label); @override String toString() { @@ -55,7 +55,7 @@ class GalleryVisualDensityValue { } @override - int get hashCode => hashValues(visualDensity, label); + int get hashCode => Object.hash(visualDensity, label); @override String toString() { diff --git a/dev/integration_tests/web/lib/stack_trace.dart b/dev/integration_tests/web/lib/stack_trace.dart index 21d4eb42d1..6bc160c9b1 100644 --- a/dev/integration_tests/web/lib/stack_trace.dart +++ b/dev/integration_tests/web/lib/stack_trace.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'dart:html' as html; -import 'dart:ui'; import 'package:collection/collection.dart'; import 'package:flutter/foundation.dart'; @@ -33,7 +32,7 @@ const List expectedDebugStackFrames = [ packageScheme: 'package', package: 'packages', packagePath: 'web_integration/stack_trace.dart', - line: 120, + line: 119, column: 3, className: '', method: 'baz', @@ -44,7 +43,7 @@ const List expectedDebugStackFrames = [ packageScheme: 'package', package: 'packages', packagePath: 'web_integration/stack_trace.dart', - line: 115, + line: 114, column: 3, className: '', method: 'bar', @@ -55,7 +54,7 @@ const List expectedDebugStackFrames = [ packageScheme: 'package', package: 'packages', packagePath: 'web_integration/stack_trace.dart', - line: 110, + line: 109, column: 3, className: '', method: 'foo', @@ -154,7 +153,7 @@ class StackFrameEquality implements Equality { // TODO(dnfield): This ignore shouldn't be necessary, see https://github.com/dart-lang/sdk/issues/46477 @override int hash(StackFrame e) { // ignore: avoid_renaming_method_parameters - return hashValues(e.number, e.packageScheme, e.package, e.packagePath, e.line, e.column, e.className, e.method); + return Object.hash(e.number, e.packageScheme, e.package, e.packagePath, e.line, e.column, e.className, e.method); } @override diff --git a/examples/api/lib/material/autocomplete/autocomplete.1.dart b/examples/api/lib/material/autocomplete/autocomplete.1.dart index d4da62e74d..d6031f4a8f 100644 --- a/examples/api/lib/material/autocomplete/autocomplete.1.dart +++ b/examples/api/lib/material/autocomplete/autocomplete.1.dart @@ -50,7 +50,7 @@ class User { } @override - int get hashCode => hashValues(email, name); + int get hashCode => Object.hash(email, name); } class AutocompleteBasicUserExample extends StatelessWidget { diff --git a/examples/api/lib/widgets/autocomplete/raw_autocomplete.1.dart b/examples/api/lib/widgets/autocomplete/raw_autocomplete.1.dart index ced20be36b..bdc4803ceb 100644 --- a/examples/api/lib/widgets/autocomplete/raw_autocomplete.1.dart +++ b/examples/api/lib/widgets/autocomplete/raw_autocomplete.1.dart @@ -52,7 +52,7 @@ class User { } @override - int get hashCode => hashValues(email, name); + int get hashCode => Object.hash(email, name); } class AutocompleteCustomTypeExample extends StatelessWidget { diff --git a/packages/flutter/lib/src/foundation/README.md b/packages/flutter/lib/src/foundation/README.md index 8f62a9b84d..5e4de0755a 100644 --- a/packages/flutter/lib/src/foundation/README.md +++ b/packages/flutter/lib/src/foundation/README.md @@ -3,9 +3,9 @@ nothing but core Dart packages. They can't depend on `dart:ui`, they can't depend on any `package:`, and they can't depend on anything outside this directory. -Currently they do depend on dart:ui, but only for `VoidCallback` and -`hashValues` (and maybe one day `hashList` and `lerpDouble`), which -are all intended to be moved out of `dart:ui` and into `dart:core`. +Currently they do depend on dart:ui, but only for `VoidCallback` (and +maybe one day `lerpDouble`), which are all intended to be moved out +of `dart:ui` and into `dart:core`. There is currently also an unfortunate dependency on the platform dispatcher logic (SingletonFlutterWindow, Brightness, diff --git a/packages/flutter/lib/src/material/expansion_tile_theme.dart b/packages/flutter/lib/src/material/expansion_tile_theme.dart index d2c22a6e99..2f493f2055 100644 --- a/packages/flutter/lib/src/material/expansion_tile_theme.dart +++ b/packages/flutter/lib/src/material/expansion_tile_theme.dart @@ -123,7 +123,7 @@ class ExpansionTileThemeData with Diagnosticable { @override int get hashCode { - return hashValues( + return Object.hash( backgroundColor, collapsedBackgroundColor, tilePadding, diff --git a/packages/flutter/lib/src/painting/basic_types.dart b/packages/flutter/lib/src/painting/basic_types.dart index 373c37d151..460aeef06c 100644 --- a/packages/flutter/lib/src/painting/basic_types.dart +++ b/packages/flutter/lib/src/painting/basic_types.dart @@ -41,7 +41,8 @@ export 'dart:ui' show TextPosition, TileMode, VertexMode, - // TODO(werainkhatri): remove these after all the dependencies are migrated + // TODO(werainkhatri): remove these after their deprecation period in engine + // https://github.com/flutter/flutter/pull/99505 hashValues, hashList; diff --git a/packages/flutter/lib/src/widgets/shortcuts.dart b/packages/flutter/lib/src/widgets/shortcuts.dart index da14b09698..9fdbe43deb 100644 --- a/packages/flutter/lib/src/widgets/shortcuts.dart +++ b/packages/flutter/lib/src/widgets/shortcuts.dart @@ -121,7 +121,7 @@ class KeySet { : Object.hash(h2, h1); } - // Sort key hash codes and feed to hashList to ensure the aggregate + // Sort key hash codes and feed to Object.hashAll to ensure the aggregate // hash code does not depend on the key order. final List sortedHashes = length == 3 ? _tempHashStore3 diff --git a/packages/flutter/test/material/animated_icons_test.dart b/packages/flutter/test/material/animated_icons_test.dart index 57ae8a5f35..66d9c19ef1 100644 --- a/packages/flutter/test/material/animated_icons_test.dart +++ b/packages/flutter/test/material/animated_icons_test.dart @@ -90,7 +90,7 @@ class RecordedScale extends RecordedCanvasCall { } @override - int get hashCode => hashValues(sx, sy); + int get hashCode => Object.hash(sx, sy); } void main() { diff --git a/packages/flutter_goldens/test/flutter_goldens_test.dart b/packages/flutter_goldens/test/flutter_goldens_test.dart index feb3ef75fd..4363c0416d 100644 --- a/packages/flutter_goldens/test/flutter_goldens_test.dart +++ b/packages/flutter_goldens/test/flutter_goldens_test.dart @@ -8,7 +8,6 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io' hide Directory; import 'dart:typed_data'; -import 'dart:ui' show hashValues, hashList; import 'package:file/file.dart'; import 'package:file/memory.dart'; @@ -873,7 +872,7 @@ class RunInvocation { final String? workingDirectory; @override - int get hashCode => hashValues(hashList(command), workingDirectory); + int get hashCode => Object.hash(Object.hashAll(command), workingDirectory); bool _commandEquals(List other) { if (other == command) { diff --git a/packages/flutter_test/lib/src/image.dart b/packages/flutter_test/lib/src/image.dart index 55ca49295a..c5b8065abb 100644 --- a/packages/flutter_test/lib/src/image.dart +++ b/packages/flutter_test/lib/src/image.dart @@ -6,8 +6,6 @@ import 'dart:async'; import 'dart:typed_data'; import 'dart:ui' as ui; -import 'package:flutter/painting.dart'; - import 'test_async_utils.dart'; final Map _cache = {}; @@ -35,7 +33,7 @@ Future createTestImage({ assert(height != null && height > 0); assert(cache != null); - final int cacheKey = hashValues(width, height); + final int cacheKey = Object.hash(width, height); if (cache && _cache.containsKey(cacheKey)) { return _cache[cacheKey]!.clone(); } diff --git a/packages/flutter_test/lib/src/window.dart b/packages/flutter_test/lib/src/window.dart index bf43a492f8..aeed9acee1 100644 --- a/packages/flutter_test/lib/src/window.dart +++ b/packages/flutter_test/lib/src/window.dart @@ -581,7 +581,7 @@ class FakeAccessibilityFeatures implements ui.AccessibilityFeatures { } @override - int get hashCode => ui.hashValues(accessibleNavigation, invertColors, disableAnimations, boldText, reduceMotion, highContrast); + int get hashCode => Object.hash(accessibleNavigation, invertColors, disableAnimations, boldText, reduceMotion, highContrast); /// This gives us some grace time when the dart:ui side adds something to /// [AccessibilityFeatures], and makes things easier when we do rolls to diff --git a/packages/flutter_test/test/matchers_test.dart b/packages/flutter_test/test/matchers_test.dart index 3877dd0435..54831855c2 100644 --- a/packages/flutter_test/test/matchers_test.dart +++ b/packages/flutter_test/test/matchers_test.dart @@ -738,5 +738,5 @@ class _CustomColor extends Color { bool operator ==(Object other) => isEqual ?? super == other; @override - int get hashCode => hashValues(super.hashCode, isEqual); + int get hashCode => Object.hash(super.hashCode, isEqual); } diff --git a/packages/flutter_tools/lib/src/commands/update_packages.dart b/packages/flutter_tools/lib/src/commands/update_packages.dart index dc7b18bf93..ce230c0dfd 100644 --- a/packages/flutter_tools/lib/src/commands/update_packages.dart +++ b/packages/flutter_tools/lib/src/commands/update_packages.dart @@ -1066,7 +1066,7 @@ class PubspecLine { class PubspecChecksum extends PubspecLine { PubspecChecksum(this.value, String line) : super(line); - /// The checksum value, computed using [hashValues] over the direct, dev, + /// The checksum value, computed using [Object.hash] over the direct, dev, /// and special dependencies sorted lexically. /// /// If the line cannot be parsed, [value] will be null.