diff --git a/engine/src/flutter/lib/ui/painting.dart b/engine/src/flutter/lib/ui/painting.dart index 0a6ccf3331..b0f5a60a7c 100644 --- a/engine/src/flutter/lib/ui/painting.dart +++ b/engine/src/flutter/lib/ui/painting.dart @@ -3589,10 +3589,11 @@ class ColorFilter implements ImageFilter { } return _ColorFilter.mode(this); case _kTypeMatrix: - if (_matrix == null) { + final List? matrix = _matrix; + if (matrix == null) { return null; } - assert(_matrix!.length == 20, 'Color Matrix must have 20 entries.'); + assert(matrix.length == 20, 'Color Matrix must have 20 entries.'); return _ColorFilter.matrix(this); case _kTypeLinearToSrgbGamma: return _ColorFilter.linearToSrgbGamma(this); @@ -3616,7 +3617,10 @@ class ColorFilter implements ImageFilter { } @override - int get hashCode => Object.hash(_color, _blendMode, _matrix == null ? null : Object.hashAll(_matrix!), _type); + int get hashCode { + final List? matrix = _matrix; + return Object.hash(_color, _blendMode, matrix == null ? null : Object.hashAll(matrix), _type); + } @override String get _shortDescription { diff --git a/engine/src/flutter/lib/ui/platform_dispatcher.dart b/engine/src/flutter/lib/ui/platform_dispatcher.dart index d529fac09e..ebcc86456d 100644 --- a/engine/src/flutter/lib/ui/platform_dispatcher.dart +++ b/engine/src/flutter/lib/ui/platform_dispatcher.dart @@ -2315,8 +2315,9 @@ class Locale { if (scriptCode != null && scriptCode!.isNotEmpty) { out.write('$separator$scriptCode'); } - if (_countryCode != null && _countryCode!.isNotEmpty) { - out.write('$separator$countryCode'); + final String? countryCode = _countryCode; + if (countryCode != null && countryCode.isNotEmpty) { + out.write('$separator${this.countryCode}'); } return out.toString(); } diff --git a/engine/src/flutter/lib/ui/text.dart b/engine/src/flutter/lib/ui/text.dart index 95095a4d88..a77396ca83 100644 --- a/engine/src/flutter/lib/ui/text.dart +++ b/engine/src/flutter/lib/ui/text.dart @@ -1550,26 +1550,32 @@ class TextStyle { } @override - int get hashCode => Object.hash( - Object.hashAll(_encoded), - _leadingDistribution, - _fontFamily, - _fontFamilyFallback, - _fontSize, - _letterSpacing, - _wordSpacing, - _height, - _locale, - _background, - _foreground, - _shadows == null ? null : Object.hashAll(_shadows!), - _decorationThickness, - _fontFeatures == null ? null : Object.hashAll(_fontFeatures!), - _fontVariations == null ? null : Object.hashAll(_fontVariations!), - ); + int get hashCode { + final List? shadows = _shadows; + final List? fontFeatures = _fontFeatures; + final List? fontVariations = _fontVariations; + return Object.hash( + Object.hashAll(_encoded), + _leadingDistribution, + _fontFamily, + _fontFamilyFallback, + _fontSize, + _letterSpacing, + _wordSpacing, + _height, + _locale, + _background, + _foreground, + shadows == null ? null : Object.hashAll(shadows), + _decorationThickness, + fontFeatures == null ? null : Object.hashAll(fontFeatures), + fontVariations == null ? null : Object.hashAll(fontVariations), + ); + } @override String toString() { + final List? fontFamilyFallback = _fontFamilyFallback; return 'TextStyle(' 'color: ${ _encoded[0] & 0x00002 == 0x00002 ? Color(_encoded[1]) : "unspecified"}, ' 'decoration: ${ _encoded[0] & 0x00004 == 0x00004 ? TextDecoration._(_encoded[2]) : "unspecified"}, ' @@ -1583,8 +1589,8 @@ class TextStyle { 'fontFamily: ${ _encoded[0] & 0x00200 == 0x00200 && _fontFamily != '' ? _fontFamily : "unspecified"}, ' 'fontFamilyFallback: ${ _encoded[0] & 0x00200 == 0x00200 - && _fontFamilyFallback != null - && _fontFamilyFallback!.isNotEmpty ? _fontFamilyFallback : "unspecified"}, ' + && fontFamilyFallback != null + && fontFamilyFallback.isNotEmpty ? fontFamilyFallback : "unspecified"}, ' 'fontSize: ${ _encoded[0] & 0x00400 == 0x00400 ? _fontSize : "unspecified"}, ' 'letterSpacing: ${ _encoded[0] & 0x00800 == 0x00800 ? "${_letterSpacing}x" : "unspecified"}, ' 'wordSpacing: ${ _encoded[0] & 0x01000 == 0x01000 ? "${_wordSpacing}x" : "unspecified"}, ' @@ -3185,8 +3191,9 @@ base class _NativeParagraphBuilder extends NativeFieldWrapperClass1 implements P void pushStyle(TextStyle style) { final List fullFontFamilies = []; fullFontFamilies.add(style._fontFamily); - if (style._fontFamilyFallback != null) { - fullFontFamilies.addAll(style._fontFamilyFallback!); + final List? fontFamilyFallback = style._fontFamilyFallback; + if (fontFamilyFallback != null) { + fullFontFamilies.addAll(fontFamilyFallback); } final Int32List encoded = style._encoded; diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/platform_views/message_handler.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/platform_views/message_handler.dart index b6a5f4533c..c55380ec6a 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/platform_views/message_handler.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/platform_views/message_handler.dart @@ -98,9 +98,7 @@ class PlatformViewMessageHandler { // For now, we don't need anything fancier. If needed, this can be converted // to a PlatformViewStrategy class for each web-renderer backend? - if (_contentHandler != null) { - _contentHandler!(content); - } + _contentHandler?.call(content); callback(_codec.encodeSuccessEnvelope(null)); } diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/semantics/semantics.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/semantics/semantics.dart index 8f19b2ef10..e30f5f6e11 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/semantics/semantics.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/semantics/semantics.dart @@ -2122,14 +2122,15 @@ class EngineSemanticsOwner { // First, update each object's information about itself. This information is // later used to fix the parent-child and sibling relationships between // objects. - for (final SemanticsNodeUpdate nodeUpdate in update._nodeUpdates!) { + final List nodeUpdates = update._nodeUpdates!; + for (final SemanticsNodeUpdate nodeUpdate in nodeUpdates) { final SemanticsObject object = getOrCreateObject(nodeUpdate.id); object.updateSelf(nodeUpdate); } // Second, fix the tree structure. This is moved out into its own loop, // because each object's own information must be updated first. - for (final SemanticsNodeUpdate nodeUpdate in update._nodeUpdates!) { + for (final SemanticsNodeUpdate nodeUpdate in nodeUpdates) { final SemanticsObject object = _semanticsTree[nodeUpdate.id]!; object.updateChildren(); object._dirtyFields = 0; @@ -2193,11 +2194,14 @@ class EngineSemanticsOwner { }); // Validate that all updates were applied - for (final SemanticsNodeUpdate update in update._nodeUpdates!) { + for (final SemanticsNodeUpdate update in nodeUpdates) { // Node was added to the tree. assert(_semanticsTree.containsKey(update.id)); } + // Verify that `update._nodeUpdates` has not changed. + assert(identical(update._nodeUpdates, nodeUpdates)); + return true; }()); }