File tree 2 files changed +19
-5
lines changed
2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -450,6 +450,14 @@ void hooksTests() {
450
450
}
451
451
});
452
452
453
+ test ('deprecated region equals' , () {
454
+ // These are equal because ZR is deprecated and was mapped to CD.
455
+ const Locale x = Locale ('en' , 'ZR' );
456
+ const Locale y = Locale ('en' , 'CD' );
457
+ expectEquals (x, y);
458
+ expectEquals (x.countryCode, y.countryCode);
459
+ });
460
+
453
461
test ('Window padding/insets/viewPadding/systemGestureInsets' , () {
454
462
_callHook (
455
463
'_updateWindowMetrics' ,
Original file line number Diff line number Diff line change @@ -1992,17 +1992,23 @@ class Locale {
1992
1992
if (other is ! Locale ) {
1993
1993
return false ;
1994
1994
}
1995
- final String ? countryCode = _countryCode ;
1995
+ final String ? thisCountryCode = countryCode ;
1996
1996
final String ? otherCountryCode = other.countryCode;
1997
1997
return other.languageCode == languageCode
1998
1998
&& other.scriptCode == scriptCode // scriptCode cannot be ''
1999
- && (other.countryCode == countryCode // Treat '' as equal to null.
2000
- || otherCountryCode != null && otherCountryCode.isEmpty && countryCode == null
2001
- || countryCode != null && countryCode .isEmpty && other.countryCode == null );
1999
+ && (other.countryCode == thisCountryCode // Treat '' as equal to null.
2000
+ || otherCountryCode != null && otherCountryCode.isEmpty && thisCountryCode == null
2001
+ || thisCountryCode != null && thisCountryCode .isEmpty && other.countryCode == null );
2002
2002
}
2003
2003
2004
2004
@override
2005
- int get hashCode => hashValues (languageCode, scriptCode, countryCode == '' ? null : countryCode);
2005
+ int get hashCode => _hashCode[this ] ?? = hashValues (
2006
+ languageCode,
2007
+ scriptCode,
2008
+ countryCode == '' ? null : countryCode,
2009
+ );
2010
+ // Memoize hashCode since languageCode and countryCode require lookups.
2011
+ static final Expando <int > _hashCode = Expando <int >();
2006
2012
2007
2013
static Locale ? _cachedLocale;
2008
2014
static String ? _cachedLocaleString;
You can’t perform that action at this time.
0 commit comments