From 6bb3cbe2c4b61d1e172ec603193df0fe55ed7b41 Mon Sep 17 00:00:00 2001 From: Hampus Hammarlund Date: Sat, 23 Nov 2024 18:20:25 +0900 Subject: [PATCH] fix: fix reported crash from percent indicator dialog --- lib/ui/dialogs/percent_indicator_dialog.dart | 2 +- lib/ui/views/settings/settings_viewmodel.dart | 20 +++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/ui/dialogs/percent_indicator_dialog.dart b/lib/ui/dialogs/percent_indicator_dialog.dart index c8e02b9..f61cf88 100644 --- a/lib/ui/dialogs/percent_indicator_dialog.dart +++ b/lib/ui/dialogs/percent_indicator_dialog.dart @@ -23,7 +23,7 @@ class _PercentIndicatorDialogState extends State { initState() { super.initState(); - widget.request.data.listen((event) { + widget.request.data.listen((double event) { double newStatus = (event * 100).floorToDouble() / 100; if (newStatus != _downloadStatus) { setState(() { diff --git a/lib/ui/views/settings/settings_viewmodel.dart b/lib/ui/views/settings/settings_viewmodel.dart index 4d2978e..30dca6a 100644 --- a/lib/ui/views/settings/settings_viewmodel.dart +++ b/lib/ui/views/settings/settings_viewmodel.dart @@ -389,12 +389,20 @@ class SettingsViewModel extends BaseViewModel { final downloadResult = downloadService.downloadProperNounDictionary(); // Show percent indicator dialog - _dialogService.showCustomDialog( - variant: DialogType.percentIndicator, - title: 'Downloading proper noun dictionary', - data: downloadService.progressStream, - barrierDismissible: false, - ); + if (downloadService.progressStream != null) { + _dialogService.showCustomDialog( + variant: DialogType.percentIndicator, + title: 'Downloading proper noun dictionary', + data: downloadService.progressStream, + barrierDismissible: false, + ); + } else { + _dialogService.showCustomDialog( + variant: DialogType.progressIndicator, + title: 'Downloading proper noun dictionary', + barrierDismissible: false, + ); + } if (!await downloadResult) { _dialogService.completeDialog(DialogResponse());