Update TextStyle.hashCode to handle list fields (#50520)

This commit is contained in:
Jason Simmons 2020-02-11 14:38:03 -08:00 committed by GitHub
parent 48d5fcabbd
commit 324e20de09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -1177,7 +1177,6 @@ class TextStyle extends Diagnosticable {
color, color,
backgroundColor, backgroundColor,
fontFamily, fontFamily,
fontFamilyFallback,
fontSize, fontSize,
fontWeight, fontWeight,
fontStyle, fontStyle,
@ -1191,8 +1190,9 @@ class TextStyle extends Diagnosticable {
decoration, decoration,
decorationColor, decorationColor,
decorationStyle, decorationStyle,
shadows, hashList(shadows),
fontFeatures, hashList(fontFeatures),
hashList(fontFamilyFallback),
); );
} }

View File

@ -2,8 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // 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 'package:flutter/painting.dart';
import '../flutter_test_alternative.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'); 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: <String>['Roboto'], shadows: <ui.Shadow>[ui.Shadow()], fontFeatures: <ui.FontFeature>[ui.FontFeature('abcd')]);
const TextStyle b = TextStyle(fontFamilyFallback: <String>['Noto'], shadows: <ui.Shadow>[ui.Shadow()], fontFeatures: <ui.FontFeature>[ui.FontFeature('abcd')]);
expect(a.hashCode, a.hashCode);
expect(a.hashCode, isNot(equals(b.hashCode)));
}, skip: kIsWeb);
test('TextStyle foreground and color combos', () { test('TextStyle foreground and color combos', () {
const Color red = Color.fromARGB(255, 255, 0, 0); const Color red = Color.fromARGB(255, 255, 0, 0);
const Color blue = Color.fromARGB(255, 0, 0, 255); const Color blue = Color.fromARGB(255, 0, 0, 255);