This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -461,11 +461,23 @@ void applyWebkitClipFix(html.Element containerElement) {
461461
462462final ByteData _fontChangeMessage = JSONMessageCodec ().encodeMessage (< String , dynamic > {'type' : 'fontsChange' });
463463
464+ // Font load callbacks will typically arrive in sequence, we want to prevent
465+ // sendFontChangeMessage of causing multiple synchronous rebuilds.
466+ // This flag ensures we properly schedule a single call to framework.
467+ bool _fontChangeScheduled = false ;
468+
464469FutureOr <void > sendFontChangeMessage () async {
465470 if (window._onPlatformMessage != null )
466- window.invokeOnPlatformMessage (
467- 'flutter/system' ,
468- _fontChangeMessage,
469- (_) {},
470- );
471+ if (! _fontChangeScheduled) {
472+ _fontChangeScheduled = true ;
473+ // Batch updates into next animationframe.
474+ html.window.requestAnimationFrame ((num _) {
475+ _fontChangeScheduled = false ;
476+ window.invokeOnPlatformMessage (
477+ 'flutter/system' ,
478+ _fontChangeMessage,
479+ (_) {},
480+ );
481+ });
482+ }
471483}
Original file line number Diff line number Diff line change 33// found in the LICENSE file.
44
55// @dart = 2.6
6+ import 'dart:async' ;
67import 'dart:convert' ;
78import 'dart:html' as html;
89import 'dart:typed_data' ;
@@ -85,6 +86,9 @@ Future<void> main() async {
8586 responseType: 'arraybuffer' );
8687 await ui.loadFontFromList (Uint8List .view (response.response),
8788 fontFamily: 'Blehm' );
89+ final Completer <void > completer = Completer ();
90+ html.window.requestAnimationFrame ( (_) { completer.complete (true ); } );
91+ await (completer.future);
8892 window.onPlatformMessage = oldHandler;
8993 expect (actualName, 'flutter/system' );
9094 expect (message, '{"type":"fontsChange"}' );
You can’t perform that action at this time.
0 commit comments