Skip to content

Commit

Permalink
Add guard for stopwatch loading
Browse files Browse the repository at this point in the history
  • Loading branch information
AhsanSarwar45 committed Jun 28, 2024
1 parent 13e51b9 commit 5dfce7f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/stopwatch/screens/stopwatch_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,16 @@ class _StopwatchScreenState extends State<StopwatchScreen> {
@override
void initState() {
super.initState();
_stopwatch = loadListSync<ClockStopwatch>('stopwatches').first;
final stopwatches = loadListSync<ClockStopwatch>('stopwatches');
if(stopwatches.isEmpty){
_stopwatch = ClockStopwatch();
saveList('stopwatches', [_stopwatch]);
}
else{
_stopwatch = stopwatches.first;

}

_showNotificationSetting =
appSettings.getGroup("Stopwatch").getSetting("Show Notification");

Expand Down

0 comments on commit 5dfce7f

Please sign in to comment.