From df4bd5d0368c7df2367c8d5418f07246d90e6e03 Mon Sep 17 00:00:00 2001 From: Srujan Gaddam <58529443+srujzs@users.noreply.github.com> Date: Wed, 10 May 2023 17:18:14 -0700 Subject: [PATCH] Turn @staticInterop tear-off into closure (flutter/engine#41885) @staticInterop members will start disallowing tear-offs, so this member should turn into a closure. The static check wasn't added in time, so this is modifying the source code again. https://github.com/flutter/engine/commit/ee3ce32c7c46a872fee2e5fd4d411bf2b9669d03 was the original change, but the static error didn't make it into the Dart SDK, so this is fixing another tear-off. - [] I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on writing and running engine tests. --- .../lib/web_ui/lib/src/engine/text/font_collection.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/text/font_collection.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/text/font_collection.dart index 95d0fea5eb..cef9a9e023 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/text/font_collection.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/text/font_collection.dart @@ -130,7 +130,12 @@ class HtmlFontCollection implements FlutterFontCollection { } try { - fontFaces.forEach(domDocument.fonts!.add); + // Since we can't use tear-offs for interop members, this code is faster + // and easier to read with a for loop instead of forEach. + // ignore: prefer_foreach + for (final DomFontFace font in fontFaces) { + domDocument.fonts!.add(font); + } } catch (e) { return FontInvalidDataError(asset); }