Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
chunhtai committed Jan 9, 2020
1 parent e01c4cf commit b3da205
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
16 changes: 9 additions & 7 deletions lib/ui/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2123,14 +2123,16 @@ class ParagraphBuilder extends NativeFieldWrapperClass2 {
Future<void> loadFontFromList(Uint8List list, {String fontFamily}) {
return _futurize(
(_Callback<void> callback) => _loadFontFromList(list, callback, fontFamily)
).then((_) async {
if (window.onPlatformMessage != null)
window.onPlatformMessage(
'flutter/system',
utf8.encoder.convert(json.encode(<String, dynamic>{'type': 'fontsChange'})).buffer.asByteData(),
).then(_sendFontChangeMessage);
}

FutureOr<void> _sendFontChangeMessage(void result) async {
if (window.onPlatformMessage != null)
window.onPlatformMessage(
'flutter/system',
utf8.encoder.convert(json.encode(<String, dynamic>{'type': 'fontsChange'})).buffer.asByteData(),
(_) {},
);
});
);
}

String _loadFontFromList(Uint8List list, _Callback<void> callback, String fontFamily) native 'loadFontFromList';
18 changes: 10 additions & 8 deletions lib/web_ui/lib/src/ui/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1490,12 +1490,14 @@ abstract class ParagraphBuilder {
/// * `fontFamily`: The family name used to identify the font in text styles.
/// If this is not provided, then the family name will be extracted from the font file.
Future<void> loadFontFromList(Uint8List list, {String fontFamily}) {
return _fontCollection.loadFontFromList(list, fontFamily: fontFamily).then((_) async {
if (window.onPlatformMessage != null)
window.onPlatformMessage(
'flutter/system',
engine.JSONMessageCodec().encodeMessage(<String, dynamic>{'type': 'fontsChange'}),
(_) {},
);
});;
return _fontCollection.loadFontFromList(list, fontFamily: fontFamily).then(_sendFontChangeMessage);
}

FutureOr<void> _sendFontChangeMessage(void result) async {
if (window.onPlatformMessage != null)
window.onPlatformMessage(
'flutter/system',
engine.JSONMessageCodec().encodeMessage(<String, dynamic>{'type': 'fontsChange'}),
(_) {},
);
}

0 comments on commit b3da205

Please sign in to comment.