From 8f7730575e19cd56ae5be5d88e71d5f28cca7edc Mon Sep 17 00:00:00 2001 From: NaiJi Date: Tue, 5 Sep 2023 08:34:01 -0300 Subject: [PATCH] fix: Wrap DNS check in catch to avoid runtime crash --- .../server_installation_repository.dart | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/logic/cubit/server_installation/server_installation_repository.dart b/lib/logic/cubit/server_installation/server_installation_repository.dart index c3fd6811..7f33d4f7 100644 --- a/lib/logic/cubit/server_installation/server_installation_repository.dart +++ b/lib/logic/cubit/server_installation/server_installation_repository.dart @@ -218,19 +218,23 @@ class ServerInstallationRepository { final Map skippedMatches, ) async { final Map matches = {}; - await InternetAddress.lookup(domainName!).then( - (final records) { - for (final record in records) { - if (skippedMatches[record.host] ?? false) { - matches[record.host] = true; - continue; + try { + await InternetAddress.lookup(domainName!).then( + (final records) { + for (final record in records) { + if (skippedMatches[record.host] ?? false) { + matches[record.host] = true; + continue; + } + if (record.address == ip4!) { + matches[record.host] = true; + } } - if (record.address == ip4!) { - matches[record.host] = true; - } - } - }, - ); + }, + ); + } catch (e) { + print(e); + } return matches; }