Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address LateInitializationError on swap timers #885

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/bloc/rev_swap_in_progress/rev_swap_in_progress_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class RevSwapsInProgressBloc extends Cubit<RevSwapsInProgressState> {
await _refreshInProgressReverseSwaps(showLoader: true).whenComplete(() => _startPolling());
}

late Timer timer;
Timer? timer;

void _startPolling() {
timer = Timer.periodic(const Duration(seconds: 30), (_) => _refreshInProgressReverseSwaps());
Expand Down Expand Up @@ -59,9 +59,9 @@ class RevSwapsInProgressBloc extends Cubit<RevSwapsInProgressState> {
}

void _stopPolling() {
if (timer.isActive) {
if (timer != null && timer!.isActive) {
_log.info("Stop polling for reverse swaps in progress.");
timer.cancel();
timer!.cancel();
}
}

Expand Down
6 changes: 3 additions & 3 deletions lib/bloc/swap_in_progress/swap_in_progress_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class SwapInProgressBloc extends Cubit<SwapInProgressState> {
await _refreshAddresses(showLoader: true).whenComplete(() => _startPolling());
}

late Timer timer;
Timer? timer;

void _startPolling() {
timer = Timer.periodic(const Duration(seconds: 30), (_) => _refreshAddresses());
Expand Down Expand Up @@ -56,9 +56,9 @@ class SwapInProgressBloc extends Cubit<SwapInProgressState> {
}

void _stopPolling() {
if (timer.isActive) {
if (timer != null && timer!.isActive) {
_log.info("Stop polling for swaps in address.");
timer.cancel();
timer!.cancel();
}
}

Expand Down
Loading