From 5dfce7f4197802bdf801c718c9cbfc9ab45a15cb Mon Sep 17 00:00:00 2001 From: AhsanSarwar45 Date: Fri, 28 Jun 2024 23:48:04 +0500 Subject: [PATCH] Add guard for stopwatch loading --- lib/stopwatch/screens/stopwatch_screen.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/stopwatch/screens/stopwatch_screen.dart b/lib/stopwatch/screens/stopwatch_screen.dart index 68a3bf13..f7a026bd 100644 --- a/lib/stopwatch/screens/stopwatch_screen.dart +++ b/lib/stopwatch/screens/stopwatch_screen.dart @@ -39,8 +39,16 @@ class _StopwatchScreenState extends State { @override void initState() { super.initState(); - _stopwatch = loadListSync('stopwatches').first; + final stopwatches = loadListSync('stopwatches'); + if(stopwatches.isEmpty){ + _stopwatch = ClockStopwatch(); + saveList('stopwatches', [_stopwatch]); + } + else{ + _stopwatch = stopwatches.first; + } + _showNotificationSetting = appSettings.getGroup("Stopwatch").getSetting("Show Notification");