diff --git a/lib/bloc/rev_swap_in_progress/rev_swap_in_progress_bloc.dart b/lib/bloc/rev_swap_in_progress/rev_swap_in_progress_bloc.dart index e09af8864..86da59b1f 100644 --- a/lib/bloc/rev_swap_in_progress/rev_swap_in_progress_bloc.dart +++ b/lib/bloc/rev_swap_in_progress/rev_swap_in_progress_bloc.dart @@ -23,7 +23,7 @@ class RevSwapsInProgressBloc extends Cubit { await _refreshInProgressReverseSwaps(showLoader: true).whenComplete(() => _startPolling()); } - late Timer timer; + Timer? timer; void _startPolling() { timer = Timer.periodic(const Duration(seconds: 30), (_) => _refreshInProgressReverseSwaps()); @@ -59,9 +59,9 @@ class RevSwapsInProgressBloc extends Cubit { } void _stopPolling() { - if (timer.isActive) { + if (timer != null && timer!.isActive) { _log.info("Stop polling for reverse swaps in progress."); - timer.cancel(); + timer!.cancel(); } } diff --git a/lib/bloc/swap_in_progress/swap_in_progress_bloc.dart b/lib/bloc/swap_in_progress/swap_in_progress_bloc.dart index ea85e5f9b..aa588a3b5 100644 --- a/lib/bloc/swap_in_progress/swap_in_progress_bloc.dart +++ b/lib/bloc/swap_in_progress/swap_in_progress_bloc.dart @@ -23,7 +23,7 @@ class SwapInProgressBloc extends Cubit { await _refreshAddresses(showLoader: true).whenComplete(() => _startPolling()); } - late Timer timer; + Timer? timer; void _startPolling() { timer = Timer.periodic(const Duration(seconds: 30), (_) => _refreshAddresses()); @@ -56,9 +56,9 @@ class SwapInProgressBloc extends Cubit { } void _stopPolling() { - if (timer.isActive) { + if (timer != null && timer!.isActive) { _log.info("Stop polling for swaps in address."); - timer.cancel(); + timer!.cancel(); } }