From c983a483c68cda92da72514ec8b4cbc501c8ac23 Mon Sep 17 00:00:00 2001 From: Ferhat Date: Mon, 10 Aug 2020 17:27:26 -0700 Subject: [PATCH] Fix nullability warning and change registeredFonts to non-nullable (flutter/engine#20379) * Fix nullability warning and change registeredFonts to non-nullable * Renamed var --- .../lib/web_ui/lib/src/engine/compositor/fonts.dart | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/compositor/fonts.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/compositor/fonts.dart index 63fd131704..a26a3192ae 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/compositor/fonts.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/compositor/fonts.dart @@ -20,7 +20,7 @@ class SkiaFontCollection { >[]; /// Fonts which have been registered and loaded. - final List<_RegisteredFont?> _registeredFonts = <_RegisteredFont?>[]; + final List<_RegisteredFont> _registeredFonts = <_RegisteredFont>[]; final Set registeredFamilies = {}; @@ -30,7 +30,7 @@ class SkiaFontCollection { fontProvider = canvasKit.TypefaceFontProvider.Make(); for (var font in _registeredFonts) { - fontProvider!.registerFont(font!.bytes, font!.flutterFamily); + fontProvider!.registerFont(font.bytes, font.flutterFamily); } } @@ -40,10 +40,13 @@ class SkiaFontCollection { if (_unloadedFonts.isEmpty) { return; } - final List<_RegisteredFont?> loadedFonts = await Future.wait(_unloadedFonts); - _registeredFonts.addAll(loadedFonts.where((x) => x != null)); + for (_RegisteredFont? font in loadedFonts) { + if (font != null) { + _registeredFonts.add(font); + } + } _unloadedFonts.clear(); } @@ -136,7 +139,7 @@ class SkiaFontCollection { actualFamily = family; } - return _RegisteredFont(bytes, family, actualFamily!); + return _RegisteredFont(bytes, family, actualFamily); } String? _readActualFamilyName(Uint8List bytes) {