From 08ab47dddf14500dd675107c593f30df887c2669 Mon Sep 17 00:00:00 2001 From: Srujan Gaddam <58529443+srujzs@users.noreply.github.com> Date: Mon, 1 May 2023 16:18:32 -0700 Subject: [PATCH] Turn @staticInterop tear-off into closure (flutter/engine#41643) @staticInterop members will start disallowing tear-offs, so this member should turn into a closure. Unblocks a roll in the SDK that disallows tear-offs. ## Pre-launch Checklist - [X] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [X] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [X] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [X] I listed at least one issue that this PR fixes in the description above. - [X] 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. - [X] I updated/added relevant documentation (doc comments with `///`). - [X] I signed the [CLA]. - [X] All existing and new tests are passing. --- .../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 398e050575..5af290c663 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 @@ -194,7 +194,12 @@ class FontManager { if (_downloadedFonts.isEmpty) { return; } - _downloadedFonts.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 _downloadedFonts) { + domDocument.fonts!.add(font); + } }