From 0dd3caf99b27b22996ea4cf71d8737fe4aff4942 Mon Sep 17 00:00:00 2001 From: xavierchanth Date: Tue, 8 Oct 2024 19:40:04 -0400 Subject: [PATCH] fix: handle empty file case --- .../npt_flutter/lib/features/onboarding/util/atsign_manager.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/dart/npt_flutter/lib/features/onboarding/util/atsign_manager.dart b/packages/dart/npt_flutter/lib/features/onboarding/util/atsign_manager.dart index 198c0c54f..6e9dbd2a1 100644 --- a/packages/dart/npt_flutter/lib/features/onboarding/util/atsign_manager.dart +++ b/packages/dart/npt_flutter/lib/features/onboarding/util/atsign_manager.dart @@ -140,6 +140,7 @@ Future> _getAtsignInformationFromFile([File? f]) async { if (f == null) throw Exception("Failed to get the Atsign Information File"); try { var contents = await f.readAsString(); + if (contents.trim().isEmpty) return []; var json = jsonDecode(contents); if (json is! Iterable) { return []; // The file format is invalid so return as a non-error and we will overwrite it