diff --git a/lib/main.dart b/lib/main.dart index d9a0ba5fc..12b13ab2d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -106,9 +106,11 @@ Future _runBackgroundTask(String taskId, {String mode = 'normal'}) async { await _sync('bgTaskActiveProcess'); BackgroundFetch.finish(taskId); } else { + // ignore: unawaited_futures _runWithLogs( () async { _logger.info("Starting background task in $mode mode"); + // ignore: unawaited_futures _runInBackground(taskId); }, prefix: "[bg]", @@ -152,7 +154,7 @@ Future _init(bool isBackground, {String via = ''}) async { _logger.info("Initializing... inBG =$isBackground via: $via"); final SharedPreferences preferences = await SharedPreferences.getInstance(); await _logFGHeartBeatInfo(); - _scheduleHeartBeat(preferences, isBackground); + unawaited(_scheduleHeartBeat(preferences, isBackground)); AppLifecycleService.instance.init(preferences); if (isBackground) { AppLifecycleService.instance.onAppInBackground('init via: $via'); @@ -185,15 +187,15 @@ Future _init(bool isBackground, {String via = ''}) async { SearchService.instance.init(); StorageBonusService.instance.init(preferences); if (Platform.isIOS) { + // ignore: unawaited_futures PushService.instance.init().then((_) { FirebaseMessaging.onBackgroundMessage( _firebaseMessagingBackgroundHandler, ); }); } - FeatureFlagService.instance.init(); - SemanticSearchService.instance.init(preferences); - + unawaited(FeatureFlagService.instance.init()); + unawaited(SemanticSearchService.instance.init(preferences)); // Can not including existing tf/ml binaries as they are not being built // from source. // See https://gitlab.com/fdroid/fdroiddata/-/merge_requests/12671#note_1294346819 @@ -242,6 +244,7 @@ Future _scheduleHeartBeat( DateTime.now().microsecondsSinceEpoch, ); Future.delayed(kHeartBeatFrequency, () async { + // ignore: unawaited_futures _scheduleHeartBeat(prefs, isBackground); }); } @@ -281,7 +284,7 @@ Future _killBGTask([String? taskId]) async { DateTime.now().microsecondsSinceEpoch, ); final prefs = await SharedPreferences.getInstance(); - prefs.remove(kLastBGTaskHeartBeatTime); + await prefs.remove(kLastBGTaskHeartBeatTime); if (taskId != null) { BackgroundFetch.finish(taskId); } @@ -299,6 +302,7 @@ Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async { } } else { // App is dead + // ignore: unawaited_futures _runWithLogs( () async { _logger.info("Background push received"); diff --git a/lib/services/collections_service.dart b/lib/services/collections_service.dart index c17c2f4ff..ab6f7379c 100644 --- a/lib/services/collections_service.dart +++ b/lib/services/collections_service.dart @@ -147,7 +147,7 @@ class CollectionsService { ); } await _updateDB(updatedCollections); - _prefs.setInt(_collectionsSyncTimeKey, maxUpdationTime); + await _prefs.setInt(_collectionsSyncTimeKey, maxUpdationTime); watch.logAndReset("till DB insertion ${updatedCollections.length}"); for (final collection in fetchedCollections) { _cacheLocalPathAndCollection(collection); diff --git a/lib/services/entity_service.dart b/lib/services/entity_service.dart index d1194e03a..e681f37b7 100644 --- a/lib/services/entity_service.dart +++ b/lib/services/entity_service.dart @@ -142,7 +142,7 @@ class EntityService { await _db.upsertEntities(entities); } } - _prefs.setInt(_getEntityLastSyncTimePrefix(type), maxSyncTime); + await _prefs.setInt(_getEntityLastSyncTimePrefix(type), maxSyncTime); if (hasMoreItems) { _logger.info("Diff limit reached, pulling again"); await _remoteToLocalSync(type); diff --git a/lib/services/feature_flag_service.dart b/lib/services/feature_flag_service.dart index 0a630eb42..9da184a61 100644 --- a/lib/services/feature_flag_service.dart +++ b/lib/services/feature_flag_service.dart @@ -83,7 +83,7 @@ class FeatureFlagService { .getDio() .get("https://static.ente.io/feature_flags.json"); final flagsResponse = FeatureFlags.fromMap(response.data); - _prefs.setString(_featureFlagsKey, flagsResponse.toJson()); + await _prefs.setString(_featureFlagsKey, flagsResponse.toJson()); _featureFlags = flagsResponse; } catch (e) { _logger.severe("Failed to sync feature flags ", e); diff --git a/lib/services/hidden_service.dart b/lib/services/hidden_service.dart index 711b3af18..3765fd640 100644 --- a/lib/services/hidden_service.dart +++ b/lib/services/hidden_service.dart @@ -1,3 +1,4 @@ +import "dart:async"; import 'dart:convert'; import 'dart:typed_data'; @@ -149,7 +150,7 @@ extension HiddenService on CollectionsService { await dialog.hide(); } on AssertionError catch (e) { await dialog.hide(); - showErrorDialog(context, "Oops", e.message as String); + unawaited(showErrorDialog(context, "Oops", e.message as String)); return false; } catch (e, s) { _logger.severe("Could not hide", e, s); diff --git a/lib/services/local_authentication_service.dart b/lib/services/local_authentication_service.dart index 98c029d0b..4260977f6 100644 --- a/lib/services/local_authentication_service.dart +++ b/lib/services/local_authentication_service.dart @@ -24,7 +24,7 @@ class LocalAuthenticationService { Configuration.instance.shouldShowLockScreen(), ); if (!result) { - unawaited(showToast(context, infoMessage)); + showToast(context, infoMessage); return false; } else { return true; diff --git a/lib/services/local_sync_service.dart b/lib/services/local_sync_service.dart index 92ea82ab9..b480661cb 100644 --- a/lib/services/local_sync_service.dart +++ b/lib/services/local_sync_service.dart @@ -352,7 +352,7 @@ class LocalSyncService { PhotoManager.addChangeCallback((value) async { _logger.info("Something changed on disk"); _changeCallbackDebouncer.run(() async { - checkAndSync(); + unawaited(checkAndSync()); }); }); PhotoManager.startChangeNotify(); @@ -363,9 +363,9 @@ class LocalSyncService { await _existingSync!.future; } if (hasGrantedLimitedPermissions()) { - syncAll(); + unawaited(syncAll()); } else { - sync().then((value) => _refreshDeviceFolderCountAndCover()); + unawaited(sync().then((value) => _refreshDeviceFolderCountAndCover())); } } } diff --git a/lib/services/notification_service.dart b/lib/services/notification_service.dart index b0f4a2b49..ca9be19b5 100644 --- a/lib/services/notification_service.dart +++ b/lib/services/notification_service.dart @@ -75,7 +75,7 @@ class NotificationService { ?.requestPermission(); } if (result != null) { - _preferences.setBool(keyGrantedNotificationPermission, result); + await _preferences.setBool(keyGrantedNotificationPermission, result); } } diff --git a/lib/services/push_service.dart b/lib/services/push_service.dart index 1bee67a45..4ddd92c74 100644 --- a/lib/services/push_service.dart +++ b/lib/services/push_service.dart @@ -35,6 +35,7 @@ class PushService { await _configurePushToken(); } else { Bus.instance.on().listen((_) async { + // ignore: unawaited_futures _configurePushToken(); }); } diff --git a/lib/services/remote_sync_service.dart b/lib/services/remote_sync_service.dart index 9fcc172f0..45bf36bab 100644 --- a/lib/services/remote_sync_service.dart +++ b/lib/services/remote_sync_service.dart @@ -74,6 +74,7 @@ class RemoteSyncService { Bus.instance.on().listen((event) async { if (event.type == EventType.addedOrUpdated) { if (_existingSync == null) { + // ignore: unawaited_futures sync(); } } @@ -141,6 +142,7 @@ class RemoteSyncService { if (hasMoreFilesToBackup && !_shouldThrottleSync()) { // Skipping a resync to ensure that files that were ignored in this // session are not processed now + // ignore: unawaited_futures sync(); } else { _logger.info("Fire backup completed event"); @@ -959,6 +961,7 @@ class RemoteSyncService { 'creating notification for ${collection?.displayName} ' 'shared: $sharedFilesIDs, collected: $collectedFilesIDs files', ); + // ignore: unawaited_futures NotificationService.instance.showNotification( collection!.displayName, totalCount.toString() + " new 📸", diff --git a/lib/services/sync_service.dart b/lib/services/sync_service.dart index b8bd81316..8de3e3322 100644 --- a/lib/services/sync_service.dart +++ b/lib/services/sync_service.dart @@ -240,6 +240,7 @@ class SyncService { final now = DateTime.now().microsecondsSinceEpoch; if ((now - lastNotificationShownTime) > microSecondsInDay) { await _prefs.setInt(kLastStorageLimitExceededNotificationPushTime, now); + // ignore: unawaited_futures NotificationService.instance.showNotification( "Storage limit exceeded", "Sorry, we had to pause your backups", diff --git a/lib/services/update_service.dart b/lib/services/update_service.dart index be67ae225..851e7be43 100644 --- a/lib/services/update_service.dart +++ b/lib/services/update_service.dart @@ -86,6 +86,7 @@ class UpdateService { if (shouldUpdate && hasBeen3DaysSinceLastNotification && _latestVersion!.shouldNotify) { + // ignore: unawaited_futures NotificationService.instance.showNotification( "Update available", "Click to install our best version yet", diff --git a/lib/services/user_service.dart b/lib/services/user_service.dart index f6810759d..020047384 100644 --- a/lib/services/user_service.dart +++ b/lib/services/user_service.dart @@ -740,8 +740,7 @@ class UserService { ); await dialog.hide(); if (response.statusCode == 200) { - showShortToast(context, S.of(context).authenticationSuccessful) - .ignore(); + showShortToast(context, S.of(context).authenticationSuccessful); await _saveConfiguration(response); await Navigator.of(context).pushAndRemoveUntil( MaterialPageRoute( @@ -756,7 +755,7 @@ class UserService { await dialog.hide(); _logger.severe(e); if (e.response != null && e.response!.statusCode == 404) { - showToast(context, "Session expired").ignore(); + showToast(context, "Session expired"); await Navigator.of(context).pushAndRemoveUntil( MaterialPageRoute( builder: (BuildContext context) { @@ -810,7 +809,7 @@ class UserService { } on DioError catch (e) { _logger.severe(e); if (e.response != null && e.response!.statusCode == 404) { - showToast(context, S.of(context).sessionExpired).ignore(); + showToast(context, S.of(context).sessionExpired); Navigator.of(context).pushAndRemoveUntil( MaterialPageRoute( builder: (BuildContext context) { @@ -1016,11 +1015,9 @@ class UserService { ); await dialog.hide(); Bus.instance.fire(TwoFactorStatusChangeEvent(false)); - unawaited( - showShortToast( - context, - S.of(context).twofactorAuthenticationHasBeenDisabled, - ), + showShortToast( + context, + S.of(context).twofactorAuthenticationHasBeenDisabled, ); } catch (e) { await dialog.hide(); diff --git a/lib/ui/account/delete_account_page.dart b/lib/ui/account/delete_account_page.dart index f623df8b5..8aa15abec 100644 --- a/lib/ui/account/delete_account_page.dart +++ b/lib/ui/account/delete_account_page.dart @@ -1,3 +1,4 @@ +import "dart:async"; import 'dart:convert'; import "package:dropdown_button2/dropdown_button2.dart"; @@ -344,6 +345,7 @@ class _DeleteAccountPageState extends State { ], ); + // ignore: unawaited_futures showDialog( context: context, builder: (BuildContext context) { diff --git a/lib/ui/account/login_page.dart b/lib/ui/account/login_page.dart index c52f461d1..9ffc6dca6 100644 --- a/lib/ui/account/login_page.dart +++ b/lib/ui/account/login_page.dart @@ -68,7 +68,7 @@ class _LoginPageState extends State { isFormValid: _emailIsValid, buttonText: S.of(context).logInLabel, onPressedFunction: () async { - UserService.instance.setEmail(_email!); + await UserService.instance.setEmail(_email!); SrpAttributes? attr; bool isEmailVerificationEnabled = true; try { @@ -80,6 +80,7 @@ class _LoginPageState extends State { } } if (attr != null && !isEmailVerificationEnabled) { + // ignore: unawaited_futures Navigator.of(context).push( MaterialPageRoute( builder: (BuildContext context) { diff --git a/lib/ui/account/password_entry_page.dart b/lib/ui/account/password_entry_page.dart index 48505da47..2396b93e8 100644 --- a/lib/ui/account/password_entry_page.dart +++ b/lib/ui/account/password_entry_page.dart @@ -1,3 +1,5 @@ +import "dart:async"; + import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:logging/logging.dart'; @@ -445,6 +447,7 @@ class _PasswordEntryPageState extends State { await dialog.hide(); Configuration.instance.setVolatilePassword(null); Bus.instance.fire(AccountConfiguredEvent()); + // ignore: unawaited_futures Navigator.of(context).pushAndRemoveUntil( MaterialPageRoute( builder: (BuildContext context) { @@ -460,6 +463,7 @@ class _PasswordEntryPageState extends State { } } + // ignore: unawaited_futures routeToPage( context, RecoveryKeyPage( @@ -475,6 +479,7 @@ class _PasswordEntryPageState extends State { _logger.severe(e); await dialog.hide(); if (e is UnsupportedError) { + // ignore: unawaited_futures showErrorDialog( context, S.of(context).insecureDevice, diff --git a/lib/ui/account/password_reentry_page.dart b/lib/ui/account/password_reentry_page.dart index 286f97fca..5814dce9e 100644 --- a/lib/ui/account/password_reentry_page.dart +++ b/lib/ui/account/password_reentry_page.dart @@ -120,6 +120,7 @@ class _PasswordReentryPageState extends State { firstButtonLabel: S.of(context).useRecoveryKey, ); if (dialogChoice!.action == ButtonAction.first) { + // ignore: unawaited_futures Navigator.of(context).push( MaterialPageRoute( builder: (BuildContext context) { diff --git a/lib/ui/account/recovery_key_page.dart b/lib/ui/account/recovery_key_page.dart index cc33bf8e0..6b4a11624 100644 --- a/lib/ui/account/recovery_key_page.dart +++ b/lib/ui/account/recovery_key_page.dart @@ -1,3 +1,4 @@ +import "dart:async"; import 'dart:io'; import 'package:bip39/bip39.dart' as bip39; diff --git a/lib/ui/account/recovery_page.dart b/lib/ui/account/recovery_page.dart index cf48324ae..97d3bfc33 100644 --- a/lib/ui/account/recovery_page.dart +++ b/lib/ui/account/recovery_page.dart @@ -54,6 +54,7 @@ class _RecoveryPageState extends State { await Configuration.instance.recover(_recoveryKey.text.trim()); await dialog.hide(); showShortToast(context, S.of(context).recoverySuccessful); + // ignore: unawaited_futures Navigator.of(context).pushReplacement( MaterialPageRoute( builder: (BuildContext context) { @@ -72,6 +73,7 @@ class _RecoveryPageState extends State { if (e is AssertionError) { errMessage = '$errMessage : ${e.message}'; } + // ignore: unawaited_futures showErrorDialog( context, S.of(context).incorrectRecoveryKeyTitle, diff --git a/lib/ui/account/request_pwd_verification_page.dart b/lib/ui/account/request_pwd_verification_page.dart index b8d490a2d..5b9109d83 100644 --- a/lib/ui/account/request_pwd_verification_page.dart +++ b/lib/ui/account/request_pwd_verification_page.dart @@ -84,7 +84,7 @@ class _RequestPasswordVerificationPageState onPressedFunction: () async { FocusScope.of(context).unfocus(); final dialog = createProgressDialog(context, context.l10n.pleaseWait); - dialog.show(); + await dialog.show(); try { final attributes = Configuration.instance.getKeyAttributes()!; final Uint8List keyEncryptionKey = await CryptoUtil.deriveKey( @@ -98,17 +98,18 @@ class _RequestPasswordVerificationPageState keyEncryptionKey, CryptoUtil.base642bin(attributes.keyDecryptionNonce), ); - dialog.show(); + await dialog.show(); // pop await widget.onPasswordVerified(keyEncryptionKey); - dialog.hide(); + await dialog.hide(); Navigator.of(context).pop(true); } catch (e, s) { _logger.severe("Error while verifying password", e, s); - dialog.hide(); + await dialog.hide(); if (widget.onPasswordError != null) { widget.onPasswordError!(); } else { + // ignore: unawaited_futures showErrorDialog( context, context.l10n.incorrectPasswordTitle, diff --git a/lib/ui/account/sessions_page.dart b/lib/ui/account/sessions_page.dart index 418b6ea43..e4468c5e2 100644 --- a/lib/ui/account/sessions_page.dart +++ b/lib/ui/account/sessions_page.dart @@ -121,6 +121,7 @@ class _SessionsPageState extends State { } catch (e) { await dialog.hide(); _logger.severe('failed to terminate'); + // ignore: unawaited_futures showErrorDialog( context, S.of(context).oops, @@ -184,7 +185,7 @@ class _SessionsPageState extends State { if (isLoggingOutFromThisDevice) { await UserService.instance.logout(context); } else { - _terminateSession(session); + await _terminateSession(session); } }, ), diff --git a/lib/ui/account/two_factor_authentication_page.dart b/lib/ui/account/two_factor_authentication_page.dart index 63b7abf01..2e88e7277 100644 --- a/lib/ui/account/two_factor_authentication_page.dart +++ b/lib/ui/account/two_factor_authentication_page.dart @@ -114,7 +114,7 @@ class _TwoFactorAuthenticationPageState child: OutlinedButton( onPressed: _code.length == 6 ? () async { - _verifyTwoFactorCode(_code); + await _verifyTwoFactorCode(_code); } : null, child: Text(S.of(context).verify), diff --git a/lib/ui/account/two_factor_setup_page.dart b/lib/ui/account/two_factor_setup_page.dart index c7315b781..13e8a2ead 100644 --- a/lib/ui/account/two_factor_setup_page.dart +++ b/lib/ui/account/two_factor_setup_page.dart @@ -251,7 +251,7 @@ class _TwoFactorSetupPageState extends State OutlinedButton( onPressed: _code.length == 6 ? () async { - _enableTwoFactor(_code); + await _enableTwoFactor(_code); } : null, child: Text(S.of(context).confirm), diff --git a/lib/ui/account/verify_recovery_page.dart b/lib/ui/account/verify_recovery_page.dart index 619a9e090..063d5f4b1 100644 --- a/lib/ui/account/verify_recovery_page.dart +++ b/lib/ui/account/verify_recovery_page.dart @@ -97,6 +97,7 @@ class _VerifyRecoveryPageState extends State { recoveryKey = CryptoUtil.bin2hex( await UserService.instance.getOrCreateRecoveryKey(context), ); + // ignore: unawaited_futures routeToPage( context, RecoveryKeyPage( diff --git a/lib/ui/actions/collection/collection_file_actions.dart b/lib/ui/actions/collection/collection_file_actions.dart index c91394375..de748dd76 100644 --- a/lib/ui/actions/collection/collection_file_actions.dart +++ b/lib/ui/actions/collection/collection_file_actions.dart @@ -1,3 +1,5 @@ +import "dart:async"; + import 'package:flutter/cupertino.dart'; import "package:photo_manager/photo_manager.dart"; import "package:photos/core/configuration.dart"; @@ -184,7 +186,7 @@ extension CollectionFileActions on CollectionActions { if (files.isNotEmpty) { await CollectionsService.instance.addToCollection(collectionID, files); } - RemoteSyncService.instance.sync(silently: true); + unawaited(RemoteSyncService.instance.sync(silently: true)); await dialog?.hide(); return true; } catch (e, s) { @@ -214,11 +216,11 @@ extension CollectionFileActions on CollectionActions { return true; } catch (e, s) { logger.severe(e, s); - showShortToast( - context, - markAsFavorite - ? S.of(context).sorryCouldNotAddToFavorites - : S.of(context).sorryCouldNotRemoveFromFavorites, + showShortToast( + context, + markAsFavorite + ? S.of(context).sorryCouldNotAddToFavorites + : S.of(context).sorryCouldNotRemoveFromFavorites, ); } finally { await dialog.hide(); diff --git a/lib/ui/actions/collection/collection_sharing_actions.dart b/lib/ui/actions/collection/collection_sharing_actions.dart index 21d4543a2..01eddfac2 100644 --- a/lib/ui/actions/collection/collection_sharing_actions.dart +++ b/lib/ui/actions/collection/collection_sharing_actions.dart @@ -115,7 +115,7 @@ class CollectionActions { S.of(context).creatingLink, isDismissible: true, ); - dialog.show(); + await dialog.show(); try { // create album with emptyName, use collectionCreationTime on UI to // show name @@ -143,10 +143,10 @@ class CollectionActions { await collectionsService.addToCollection(collection.id, files); logger.finest("creating public link for the newly created album"); await CollectionsService.instance.createShareUrl(collection); - dialog.hide(); + await dialog.hide(); return collection; } catch (e, s) { - dialog.hide(); + await dialog.hide(); await showGenericErrorDialog(context: context, error: e); logger.severe("Failing to create link for selected files", e, s); } @@ -467,9 +467,7 @@ class CollectionActions { } if (!isCollectionOwner && split.ownedByOtherUsers.isNotEmpty) { - unawaited( - showShortToast(context, S.of(context).canOnlyRemoveFilesOwnedByYou), - ); + showShortToast(context, S.of(context).canOnlyRemoveFilesOwnedByYou); return; } diff --git a/lib/ui/actions/file/file_actions.dart b/lib/ui/actions/file/file_actions.dart index f8a0bcad9..83ba1fa72 100644 --- a/lib/ui/actions/file/file_actions.dart +++ b/lib/ui/actions/file/file_actions.dart @@ -1,3 +1,5 @@ +import "dart:async"; + import "package:flutter/cupertino.dart"; import "package:modal_bottom_sheet/modal_bottom_sheet.dart"; import "package:photos/generated/l10n.dart"; diff --git a/lib/ui/collections/album/row_item.dart b/lib/ui/collections/album/row_item.dart index 16cc44339..50b96420e 100644 --- a/lib/ui/collections/album/row_item.dart +++ b/lib/ui/collections/album/row_item.dart @@ -189,6 +189,7 @@ class AlbumRowItemWidget extends StatelessWidget { ), onTap: () async { final thumbnail = await CollectionsService.instance.getCover(c); + // ignore: unawaited_futures routeToPage( context, CollectionPage( diff --git a/lib/ui/collections/album/vertical_list.dart b/lib/ui/collections/album/vertical_list.dart index 8891cd76b..c3634995c 100644 --- a/lib/ui/collections/album/vertical_list.dart +++ b/lib/ui/collections/album/vertical_list.dart @@ -120,7 +120,7 @@ class AlbumVerticalListWidget extends StatelessWidget { } } else { Navigator.pop(context); - await showToast( + showToast( context, S.of(context).createAlbumActionHint, ); diff --git a/lib/ui/payment/stripe_subscription_page.dart b/lib/ui/payment/stripe_subscription_page.dart index 81b172bc4..9772f4ed4 100644 --- a/lib/ui/payment/stripe_subscription_page.dart +++ b/lib/ui/payment/stripe_subscription_page.dart @@ -400,13 +400,11 @@ class _StripeSubscriptionPageState extends State { : await _billingService.cancelStripeSubscription(); await _fetchSub(); } catch (e) { - unawaited( - showShortToast( - context, - isAutoRenewDisabled - ? S.of(context).failedToRenew - : S.of(context).failedToCancel, - ), + showShortToast( + context, + isAutoRenewDisabled + ? S.of(context).failedToRenew + : S.of(context).failedToCancel, ); } await _dialog.hide(); diff --git a/lib/ui/settings/backup/backup_section_widget.dart b/lib/ui/settings/backup/backup_section_widget.dart index 60d144f99..ac57945fe 100644 --- a/lib/ui/settings/backup/backup_section_widget.dart +++ b/lib/ui/settings/backup/backup_section_widget.dart @@ -225,7 +225,7 @@ class BackupSectionWidgetState extends State { showShortToast( context, S.of(context).remindToEmptyEnteTrash, - ).ignore(); + ); }, ); } diff --git a/lib/ui/settings/debug_section_widget.dart b/lib/ui/settings/debug_section_widget.dart index 944a37120..039655ca3 100644 --- a/lib/ui/settings/debug_section_widget.dart +++ b/lib/ui/settings/debug_section_widget.dart @@ -50,7 +50,7 @@ class DebugSectionWidget extends StatelessWidget { trailingIconIsMuted: true, onTap: () async { await LocalSyncService.instance.resetLocalSync(); - showShortToast(context, "Done").ignore(); + showShortToast(context, "Done"); }, ), sectionOptionSpacing, @@ -64,7 +64,7 @@ class DebugSectionWidget extends StatelessWidget { onTap: () async { await IgnoredFilesService.instance.reset(); SyncService.instance.sync().ignore(); - showShortToast(context, "Done").ignore(); + showShortToast(context, "Done"); }, ), sectionOptionSpacing, diff --git a/lib/ui/settings/security_section_widget.dart b/lib/ui/settings/security_section_widget.dart index 1d2b9e916..7805167f9 100644 --- a/lib/ui/settings/security_section_widget.dart +++ b/lib/ui/settings/security_section_widget.dart @@ -279,7 +279,7 @@ class _SecuritySectionWidgetState extends State { } await UserService.instance.updateEmailMFA(isEnabled); } catch (e) { - showToast(context, S.of(context).somethingWentWrong).ignore(); + showToast(context, S.of(context).somethingWentWrong); } } } diff --git a/lib/ui/tabs/shared/empty_state.dart b/lib/ui/tabs/shared/empty_state.dart index 0aa14efe0..9196a52c9 100644 --- a/lib/ui/tabs/shared/empty_state.dart +++ b/lib/ui/tabs/shared/empty_state.dart @@ -139,7 +139,7 @@ class OutgoingAlbumEmptyState extends StatelessWidget { labelText: S.of(context).shareYourFirstAlbum, icon: Icons.add, onTap: () async { - await showToast( + showToast( context, S.of(context).shareAlbumHint, ); diff --git a/lib/ui/viewer/actions/file_selection_actions_widget.dart b/lib/ui/viewer/actions/file_selection_actions_widget.dart index 50d6f349b..38524949e 100644 --- a/lib/ui/viewer/actions/file_selection_actions_widget.dart +++ b/lib/ui/viewer/actions/file_selection_actions_widget.dart @@ -502,11 +502,9 @@ class _FileSelectionActionsWidgetState Future _onCreatedSharedLinkClicked() async { if (split.ownedByCurrentUser.isEmpty) { - unawaited( - showShortToast( - context, - S.of(context).canOnlyCreateLinkForFilesOwnedByYou, - ), + showShortToast( + context, + S.of(context).canOnlyCreateLinkForFilesOwnedByYou, ); return; } @@ -570,7 +568,7 @@ class _FileSelectionActionsWidgetState final String url = "${_cachedCollectionForSharedLink!.publicURLs?.first?.url}#$collectionKey"; await Clipboard.setData(ClipboardData(text: url)); - unawaited(showShortToast(context, S.of(context).linkCopiedToClipboard)); + showShortToast(context, S.of(context).linkCopiedToClipboard); } } diff --git a/lib/ui/viewer/file/zoomable_image.dart b/lib/ui/viewer/file/zoomable_image.dart index 8f371032e..5a1d47b29 100644 --- a/lib/ui/viewer/file/zoomable_image.dart +++ b/lib/ui/viewer/file/zoomable_image.dart @@ -22,7 +22,6 @@ import 'package:photos/ui/common/loading_widget.dart'; import 'package:photos/utils/file_util.dart'; import 'package:photos/utils/image_util.dart'; import 'package:photos/utils/thumbnail_util.dart'; -import "package:photos/utils/toast_util.dart"; class ZoomableImage extends StatefulWidget { final EnteFile photo; @@ -262,12 +261,6 @@ class _ZoomableImageState extends State final bool shouldFixPosition = previewImageProvider != null && _isZooming; ImageInfo? finalImageInfo; if (shouldFixPosition) { - if (kDebugMode) { - showToast( - context, - 'Updating photo scale zooming and scale: ${_photoViewController.scale}', - ).ignore(); - } final prevImageInfo = await getImageInfo(previewImageProvider); finalImageInfo = await getImageInfo(finalImageProvider); final scale = _photoViewController.scale! / @@ -303,9 +296,6 @@ class _ZoomableImageState extends State if (h != enteFile.height || w != enteFile.width) { final logMessage = 'Updating aspect ratio for from ${enteFile.height}x${enteFile.width} to ${h}x$w'; - if (kDebugMode && (enteFile.height != 0 || enteFile.width != 0)) { - showToast(context, logMessage).ignore(); - } _logger.info(logMessage); await FileMagicService.instance.updatePublicMagicMetadata([ enteFile, diff --git a/lib/ui/viewer/file_details/favorite_widget.dart b/lib/ui/viewer/file_details/favorite_widget.dart index 4e3fb1b5f..15fb7397c 100644 --- a/lib/ui/viewer/file_details/favorite_widget.dart +++ b/lib/ui/viewer/file_details/favorite_widget.dart @@ -79,11 +79,9 @@ class _FavoriteWidgetState extends State { } catch (e, s) { _logger.severe(e, s); hasError = true; - unawaited( - showToast( - context, - S.of(context).sorryCouldNotRemoveFromFavorites, - ), + showToast( + context, + S.of(context).sorryCouldNotRemoveFromFavorites, ); } } diff --git a/lib/ui/viewer/gallery/gallery.dart b/lib/ui/viewer/gallery/gallery.dart index d0fa5b9ab..432587cf2 100644 --- a/lib/ui/viewer/gallery/gallery.dart +++ b/lib/ui/viewer/gallery/gallery.dart @@ -141,7 +141,7 @@ class GalleryState extends State { // todo: Assign ID to Gallery and fire generic event with ID & // target index/date if (mounted && event.selectedIndex == 0) { - _itemScroller.scrollTo( + await _itemScroller.scrollTo( index: 0, duration: const Duration(milliseconds: 150), ); diff --git a/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/lib/ui/viewer/gallery/gallery_app_bar_widget.dart index 58f94ba3b..c7953a7a5 100644 --- a/lib/ui/viewer/gallery/gallery_app_bar_widget.dart +++ b/lib/ui/viewer/gallery/gallery_app_bar_widget.dart @@ -131,12 +131,10 @@ class _GalleryAppBarWidgetState extends State { if (galleryType != GalleryType.ownedCollection && galleryType != GalleryType.hiddenOwnedCollection && galleryType != GalleryType.quickLink) { - unawaited( - showToast( - context, - 'Type of galler $galleryType is not supported for ' - 'rename', - ), + showToast( + context, + 'Type of galler $galleryType is not supported for ' + 'rename', ); return; @@ -269,7 +267,7 @@ class _GalleryAppBarWidgetState extends State { showToast( context, S.of(context).remindToEmptyDeviceTrash, - ).ignore(); + ); } }, ); @@ -614,7 +612,7 @@ class _GalleryAppBarWidgetState extends State { context, ); } else { - unawaited(showToast(context, S.of(context).somethingWentWrong)); + showToast(context, S.of(context).somethingWentWrong); } }, ), diff --git a/lib/ui/viewer/gallery/hooks/add_photos_sheet.dart b/lib/ui/viewer/gallery/hooks/add_photos_sheet.dart index 9f7921760..0f2510d74 100644 --- a/lib/ui/viewer/gallery/hooks/add_photos_sheet.dart +++ b/lib/ui/viewer/gallery/hooks/add_photos_sheet.dart @@ -216,7 +216,7 @@ class AddPhotosPhotoWidget extends StatelessWidget { }, ); } else { - showErrorDialog( + await showErrorDialog( context, context.l10n.oops, context.l10n.somethingWentWrong + (kDebugMode ? "\n$e" : ""), diff --git a/lib/ui/viewer/search/result/go_to_map_widget.dart b/lib/ui/viewer/search/result/go_to_map_widget.dart index e9921d363..fb449d824 100644 --- a/lib/ui/viewer/search/result/go_to_map_widget.dart +++ b/lib/ui/viewer/search/result/go_to_map_widget.dart @@ -22,6 +22,7 @@ class GoToMapWidget extends StatelessWidget { onTap: () async { final bool result = await requestForMapEnable(context); if (result) { + // ignore: unawaited_futures Navigator.of(context).push( MaterialPageRoute( builder: (context) => MapScreen( diff --git a/lib/ui/viewer/search/tab_empty_state.dart b/lib/ui/viewer/search/tab_empty_state.dart index 6e3238b56..ab072dc6f 100644 --- a/lib/ui/viewer/search/tab_empty_state.dart +++ b/lib/ui/viewer/search/tab_empty_state.dart @@ -35,6 +35,7 @@ class SearchTabEmptyState extends StatelessWidget { labelText: S.of(context).addYourPhotosNow, icon: Icons.arrow_forward_outlined, onTap: () async { + // ignore: unawaited_futures routeToPage( context, BackupFolderSelectionPage( diff --git a/lib/utils/delete_file_util.dart b/lib/utils/delete_file_util.dart index 76d74065f..bd5f76308 100644 --- a/lib/utils/delete_file_util.dart +++ b/lib/utils/delete_file_util.dart @@ -127,9 +127,9 @@ Future deleteFilesFromEverywhere( ), ); if (hasLocalOnlyFiles && Platform.isAndroid) { - await showShortToast(context, S.of(context).filesDeleted); + showShortToast(context, S.of(context).filesDeleted); } else { - await showShortToast(context, S.of(context).movedToTrash); + showShortToast(context, S.of(context).movedToTrash); } } if (uploadedFilesToBeTrashed.isNotEmpty) { diff --git a/lib/utils/file_uploader.dart b/lib/utils/file_uploader.dart index 403211f9c..653b5076b 100644 --- a/lib/utils/file_uploader.dart +++ b/lib/utils/file_uploader.dart @@ -106,6 +106,7 @@ class FileUploader { ); _logger.info("BG task was found dead, cleared all locks"); } + // ignore: unawaited_futures _pollBackgroundUploadStatus(); } Bus.instance.on().listen((event) { diff --git a/lib/utils/file_util.dart b/lib/utils/file_util.dart index ff45dfcaf..5c9dcede1 100644 --- a/lib/utils/file_util.dart +++ b/lib/utils/file_util.dart @@ -165,9 +165,10 @@ Future getFileFromServer( }, ); } - downloadFuture.then((downloadedFile) { + // ignore: unawaited_futures + downloadFuture.then((downloadedFile) async { completer.complete(downloadedFile); - _fileDownloadsInProgress.remove(downloadID); + await _fileDownloadsInProgress.remove(downloadID); _progressCallbacks.remove(downloadID); }); } @@ -197,7 +198,7 @@ Future _getLivePhotoFromServer( _downloadLivePhoto(file, progressCallback: progressCallback); } final livePhoto = await _livePhotoDownloadsTracker[file.uploadedFileID]; - _livePhotoDownloadsTracker.remove(downloadID); + await _livePhotoDownloadsTracker.remove(downloadID); if (livePhoto == null) { return null; } diff --git a/lib/utils/magic_util.dart b/lib/utils/magic_util.dart index b3459ece0..62411de43 100644 --- a/lib/utils/magic_util.dart +++ b/lib/utils/magic_util.dart @@ -116,7 +116,7 @@ Future changeSortOrder( ); } catch (e, s) { _logger.severe("failed to update collection visibility", e, s); - unawaited(showShortToast(context, S.of(context).somethingWentWrong)); + showShortToast(context, S.of(context).somethingWentWrong); rethrow; } } @@ -136,7 +136,7 @@ Future updateOrder( ); } catch (e, s) { _logger.severe("failed to update order", e, s); - unawaited(showShortToast(context, S.of(context).somethingWentWrong)); + showShortToast(context, S.of(context).somethingWentWrong); rethrow; } } @@ -162,7 +162,7 @@ Future changeCoverPhoto( ); } catch (e, s) { _logger.severe("failed to update cover", e, s); - unawaited(showShortToast(context, S.of(context).somethingWentWrong)); + showShortToast(context, S.of(context).somethingWentWrong); rethrow; } } @@ -181,7 +181,7 @@ Future editTime( ); return true; } catch (e) { - showShortToast(context, S.of(context).somethingWentWrong).ignore(); + showShortToast(context, S.of(context).somethingWentWrong); return false; } } @@ -240,7 +240,7 @@ Future editFileCaption( return true; } catch (e) { if (context != null) { - unawaited(showShortToast(context, S.of(context).somethingWentWrong)); + showShortToast(context, S.of(context).somethingWentWrong); } return false; } @@ -267,7 +267,7 @@ Future _updatePublicMetadata( await FileMagicService.instance.updatePublicMagicMetadata(files, update); if (context != null) { if (showDoneToast) { - await showShortToast(context, S.of(context).done); + showShortToast(context, S.of(context).done); } await dialog?.hide(); } diff --git a/lib/utils/toast_util.dart b/lib/utils/toast_util.dart index c333ca09a..96658ec29 100644 --- a/lib/utils/toast_util.dart +++ b/lib/utils/toast_util.dart @@ -1,3 +1,4 @@ +import "dart:async"; import 'dart:io'; import 'package:flutter/material.dart'; @@ -5,7 +6,7 @@ import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:photos/ente_theme_data.dart'; -Future showToast( +void showToast( BuildContext context, String message, { toastLength = Toast.LENGTH_LONG, @@ -13,14 +14,16 @@ Future showToast( }) async { if (Platform.isAndroid) { await Fluttertoast.cancel(); - return Fluttertoast.showToast( - msg: message, - toastLength: toastLength, - gravity: ToastGravity.BOTTOM, - timeInSecForIosWeb: 1, - backgroundColor: Theme.of(context).colorScheme.toastBackgroundColor, - textColor: Theme.of(context).colorScheme.toastTextColor, - fontSize: 16.0, + unawaited( + Fluttertoast.showToast( + msg: message, + toastLength: toastLength, + gravity: ToastGravity.BOTTOM, + timeInSecForIosWeb: 1, + backgroundColor: Theme.of(context).colorScheme.toastBackgroundColor, + textColor: Theme.of(context).colorScheme.toastTextColor, + fontSize: 16.0, + ), ); } else { EasyLoading.instance @@ -29,18 +32,20 @@ Future showToast( ..textColor = Theme.of(context).colorScheme.toastTextColor ..userInteractions = true ..loadingStyle = EasyLoadingStyle.custom; - return EasyLoading.showToast( - message, - duration: Duration( - seconds: - (toastLength == Toast.LENGTH_LONG ? iosLongToastLengthInSec : 1), + unawaited( + EasyLoading.showToast( + message, + duration: Duration( + seconds: + (toastLength == Toast.LENGTH_LONG ? iosLongToastLengthInSec : 1), + ), + toastPosition: EasyLoadingToastPosition.bottom, + dismissOnTap: false, ), - toastPosition: EasyLoadingToastPosition.bottom, - dismissOnTap: false, ); } } -Future showShortToast(context, String message) { - return showToast(context, message, toastLength: Toast.LENGTH_SHORT); +void showShortToast(context, String message) { + showToast(context, message, toastLength: Toast.LENGTH_SHORT); }