Add lint rule to warn for unawaited futures
This commit is contained in:
parent
46fe951e0d
commit
943c5edfb6
13 changed files with 47 additions and 29 deletions
|
@ -32,6 +32,7 @@ linter:
|
|||
- directives_ordering
|
||||
- always_use_package_imports
|
||||
- sort_child_properties_last
|
||||
- unawaited_futures
|
||||
|
||||
analyzer:
|
||||
errors:
|
||||
|
@ -59,6 +60,8 @@ analyzer:
|
|||
unnecessary_const: error
|
||||
cancel_subscriptions: error
|
||||
|
||||
|
||||
unawaited_futures: info # convert to warning after fixing existing issues
|
||||
invalid_dependency: info
|
||||
use_build_context_synchronously: ignore # experimental lint, requires many changes
|
||||
prefer_interpolation_to_compose_strings: ignore # later too many warnings
|
||||
|
|
|
@ -537,7 +537,7 @@ class Configuration {
|
|||
Future<void> setBackupOverMobileData(bool value) async {
|
||||
await _preferences.setBool(keyShouldBackupOverMobileData, value);
|
||||
if (value) {
|
||||
SyncService.instance.sync();
|
||||
SyncService.instance.sync().ignore();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -562,7 +562,7 @@ class Configuration {
|
|||
Future<void> setShouldBackupVideos(bool value) async {
|
||||
await _preferences.setBool(keyShouldBackupVideos, value);
|
||||
if (value) {
|
||||
SyncService.instance.sync();
|
||||
SyncService.instance.sync().ignore();
|
||||
} else {
|
||||
SyncService.instance.onVideoBackupPaused();
|
||||
}
|
||||
|
|
|
@ -188,7 +188,9 @@ Future _runWithLogs(Function() function, {String prefix = ""}) async {
|
|||
}
|
||||
|
||||
Future<void> _scheduleHeartBeat(
|
||||
SharedPreferences prefs, bool isBackground) async {
|
||||
SharedPreferences prefs,
|
||||
bool isBackground,
|
||||
) async {
|
||||
await prefs.setInt(
|
||||
isBackground ? kLastBGTaskHeartBeatTime : kLastFGTaskHeartBeatTime,
|
||||
DateTime.now().microsecondsSinceEpoch,
|
||||
|
|
|
@ -30,13 +30,13 @@ class UserRemoteFlagService {
|
|||
bool shouldShowRecoveryVerification() {
|
||||
if (!_prefs.containsKey(needRecoveryKeyVerification)) {
|
||||
// fetch the status from remote
|
||||
unawaited(_refreshRecoveryVerificationFlag());
|
||||
_refreshRecoveryVerificationFlag().ignore();
|
||||
return false;
|
||||
} else {
|
||||
final bool shouldShow = _prefs.getBool(needRecoveryKeyVerification)!;
|
||||
if (shouldShow) {
|
||||
// refresh the status to check if user marked it as done on another device
|
||||
unawaited(_refreshRecoveryVerificationFlag());
|
||||
_refreshRecoveryVerificationFlag().ignore();
|
||||
}
|
||||
return shouldShow;
|
||||
}
|
||||
|
|
|
@ -531,7 +531,7 @@ class UserService {
|
|||
);
|
||||
} catch (e) {
|
||||
await dialog.hide();
|
||||
showErrorDialog(
|
||||
await showErrorDialog(
|
||||
context,
|
||||
"Incorrect recovery key",
|
||||
"The recovery key you entered is incorrect",
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:photos/core/configuration.dart';
|
||||
|
@ -128,13 +130,15 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
|
|||
}
|
||||
await dialog.hide();
|
||||
Bus.instance.fire(SubscriptionPurchasedEvent());
|
||||
Navigator.of(context).pushAndRemoveUntil(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return const HomeWidget();
|
||||
},
|
||||
unawaited(
|
||||
Navigator.of(context).pushAndRemoveUntil(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return const HomeWidget();
|
||||
},
|
||||
),
|
||||
(route) => false,
|
||||
),
|
||||
(route) => false,
|
||||
);
|
||||
},
|
||||
),
|
||||
|
|
|
@ -116,7 +116,7 @@ class _TrashButtonWidgetState extends State<TrashButtonWidget> {
|
|||
),
|
||||
),
|
||||
),
|
||||
onPressed: () async {
|
||||
onPressed: () {
|
||||
routeToPage(
|
||||
context,
|
||||
TrashPage(),
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:photo_manager/photo_manager.dart';
|
||||
import 'package:photos/services/local_sync_service.dart';
|
||||
|
@ -17,10 +19,12 @@ class PreserveFooterWidget extends StatelessWidget {
|
|||
if (LocalSyncService.instance.hasGrantedLimitedPermissions()) {
|
||||
await PhotoManager.presentLimited();
|
||||
} else {
|
||||
routeToPage(
|
||||
context,
|
||||
const BackupFolderSelectionPage(
|
||||
buttonText: "Preserve",
|
||||
unawaited(
|
||||
routeToPage(
|
||||
context,
|
||||
const BackupFolderSelectionPage(
|
||||
buttonText: "Preserve",
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ class AboutMenuItemWidget extends StatelessWidget {
|
|||
pressedColor: getEnteColorScheme(context).fillFaint,
|
||||
trailingIcon: Icons.chevron_right_outlined,
|
||||
trailingIconIsMuted: true,
|
||||
onTap: () async {
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_sodium/flutter_sodium.dart';
|
||||
import 'package:photos/services/local_authentication_service.dart';
|
||||
|
@ -49,16 +51,18 @@ class AccountSectionWidget extends StatelessWidget {
|
|||
try {
|
||||
recoveryKey = await _getOrCreateRecoveryKey(context);
|
||||
} catch (e) {
|
||||
showGenericErrorDialog(context);
|
||||
await showGenericErrorDialog(context);
|
||||
return;
|
||||
}
|
||||
routeToPage(
|
||||
context,
|
||||
RecoveryKeyPage(
|
||||
recoveryKey,
|
||||
"OK",
|
||||
showAppBar: true,
|
||||
onDone: () {},
|
||||
unawaited(
|
||||
routeToPage(
|
||||
context,
|
||||
RecoveryKeyPage(
|
||||
recoveryKey,
|
||||
"OK",
|
||||
showAppBar: true,
|
||||
onDone: () {},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ class DangerSectionWidget extends StatelessWidget {
|
|||
],
|
||||
);
|
||||
|
||||
showDialog(
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return alert;
|
||||
|
|
|
@ -265,7 +265,7 @@ class _SecuritySectionWidgetState extends State<SecuritySectionWidget> {
|
|||
],
|
||||
);
|
||||
|
||||
showDialog(
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return alert;
|
||||
|
|
|
@ -162,7 +162,8 @@ Future<void> _downloadAndDecryptThumbnail(FileDownloadItem item) async {
|
|||
if (cachedThumbnail.existsSync()) {
|
||||
await cachedThumbnail.delete();
|
||||
}
|
||||
cachedThumbnail.writeAsBytes(data);
|
||||
// data is already cached in-memory, no need to await on dist write
|
||||
unawaited(cachedThumbnail.writeAsBytes(data));
|
||||
if (_map.containsKey(file.uploadedFileID)) {
|
||||
try {
|
||||
item.completer.complete(data);
|
||||
|
|
Loading…
Reference in a new issue