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

Commit

Permalink
clean up future chain
Browse files Browse the repository at this point in the history
  • Loading branch information
chunhtai committed Jan 16, 2020
1 parent 65d8ceb commit 90c2f81
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/ui/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2123,14 +2123,14 @@ class ParagraphBuilder extends NativeFieldWrapperClass2 {
Future<void> loadFontFromList(Uint8List list, {String fontFamily}) {
return _futurize(
(_Callback<void> callback) => _loadFontFromList(list, callback, fontFamily)
).then(_sendFontChangeMessage);
).then((_) => _sendFontChangeMessage());
}

final ByteData _fontChangeMessage = utf8.encoder.convert(
json.encode(<String, dynamic>{'type': 'fontsChange'})
).buffer.asByteData();

FutureOr<void> _sendFontChangeMessage(void result) async {
FutureOr<void> _sendFontChangeMessage() async {
if (window.onPlatformMessage != null)
window.onPlatformMessage(
'flutter/system',
Expand Down
6 changes: 4 additions & 2 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(_sendFontChangeMessage);
return _fontCollection.loadFontFromList(list, fontFamily: fontFamily).then(
(_) => _sendFontChangeMessage()
);
}

final ByteData _fontChangeMessage = engine.JSONMessageCodec().encodeMessage(<String, dynamic>{'type': 'fontsChange'});

FutureOr<void> _sendFontChangeMessage(void result) async {
FutureOr<void> _sendFontChangeMessage() async {
if (window.onPlatformMessage != null)
window.onPlatformMessage(
'flutter/system',
Expand Down

0 comments on commit 90c2f81

Please sign in to comment.