From 3b735a79658242227cf09995e9637fbc98847c03 Mon Sep 17 00:00:00 2001 From: Doflatango Date: Fri, 2 Sep 2022 19:48:35 +0800 Subject: [PATCH] Catch and ignore utf8 format exception in getFavicons() --- .../in_app_webview_controller.dart | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/src/in_app_webview/in_app_webview_controller.dart b/lib/src/in_app_webview/in_app_webview_controller.dart index b2be39c4..09fae84f 100644 --- a/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/lib/src/in_app_webview/in_app_webview_controller.dart @@ -1096,13 +1096,18 @@ class InAppWebViewController { } if (manifestFound) { - Map manifest = - json.decode(await manifestResponse!.transform(Utf8Decoder()).join()); - if (manifest.containsKey("icons")) { - for (Map icon in manifest["icons"]) { - favicons.addAll(_createFavicons(webviewUrl, assetPathBase, - icon["src"], icon["rel"], icon["sizes"], true)); + try { + Map manifest = + json.decode(await manifestResponse!.transform(Utf8Decoder()).join()); + if (manifest.containsKey("icons")) { + for (Map icon in manifest["icons"]) { + favicons.addAll(_createFavicons(webviewUrl, assetPathBase, + icon["src"], icon["rel"], icon["sizes"], true)); + } } + } on FormatException catch (_) { + /// The [manifestResponse] might not has a valid JSON string, catch and + /// ignore the error } }