From 324e20de09c60878b9f13af93f024dded4ca6d84 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Tue, 11 Feb 2020 14:38:03 -0800 Subject: [PATCH] Update TextStyle.hashCode to handle list fields (#50520) --- packages/flutter/lib/src/painting/text_style.dart | 6 +++--- packages/flutter/test/painting/text_style_test.dart | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/flutter/lib/src/painting/text_style.dart b/packages/flutter/lib/src/painting/text_style.dart index 5731ae7c47..2d48ef6233 100644 --- a/packages/flutter/lib/src/painting/text_style.dart +++ b/packages/flutter/lib/src/painting/text_style.dart @@ -1177,7 +1177,6 @@ class TextStyle extends Diagnosticable { color, backgroundColor, fontFamily, - fontFamilyFallback, fontSize, fontWeight, fontStyle, @@ -1191,8 +1190,9 @@ class TextStyle extends Diagnosticable { decoration, decorationColor, decorationStyle, - shadows, - fontFeatures, + hashList(shadows), + hashList(fontFeatures), + hashList(fontFamilyFallback), ); } diff --git a/packages/flutter/test/painting/text_style_test.dart b/packages/flutter/test/painting/text_style_test.dart index b8ae03fefd..ec2875c0de 100644 --- a/packages/flutter/test/painting/text_style_test.dart +++ b/packages/flutter/test/painting/text_style_test.dart @@ -2,8 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:ui' as ui show TextStyle, ParagraphStyle; +import 'dart:ui' as ui show TextStyle, ParagraphStyle, FontFeature, Shadow; +import 'package:flutter/foundation.dart'; import 'package:flutter/painting.dart'; import '../flutter_test_alternative.dart'; @@ -256,6 +257,13 @@ void main() { expect(TextStyle.lerp(foo.merge(bar), baz, 0.51).copyWith().debugLabel, '(lerp((foo).merge(bar) ⎯0.5→ baz)).copyWith'); }); + test('TextStyle.hashCode', () { + const TextStyle a = TextStyle(fontFamilyFallback: ['Roboto'], shadows: [ui.Shadow()], fontFeatures: [ui.FontFeature('abcd')]); + const TextStyle b = TextStyle(fontFamilyFallback: ['Noto'], shadows: [ui.Shadow()], fontFeatures: [ui.FontFeature('abcd')]); + expect(a.hashCode, a.hashCode); + expect(a.hashCode, isNot(equals(b.hashCode))); + }, skip: kIsWeb); + test('TextStyle foreground and color combos', () { const Color red = Color.fromARGB(255, 255, 0, 0); const Color blue = Color.fromARGB(255, 0, 0, 255);