Catch and ignore utf8 format exception in getFavicons()

This commit is contained in:
Doflatango 2022-09-02 19:48:35 +08:00
parent ee1b0d7ff7
commit 3b735a7965

View File

@ -1096,13 +1096,18 @@ class InAppWebViewController {
}
if (manifestFound) {
Map<String, dynamic> manifest =
json.decode(await manifestResponse!.transform(Utf8Decoder()).join());
if (manifest.containsKey("icons")) {
for (Map<String, dynamic> icon in manifest["icons"]) {
favicons.addAll(_createFavicons(webviewUrl, assetPathBase,
icon["src"], icon["rel"], icon["sizes"], true));
try {
Map<String, dynamic> manifest =
json.decode(await manifestResponse!.transform(Utf8Decoder()).join());
if (manifest.containsKey("icons")) {
for (Map<String, dynamic> 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
}
}