Enable avoid_void_async lint

This commit is contained in:
Ming Ming 2022-07-29 02:45:43 +08:00
parent 65d4268954
commit 20fac885a9
17 changed files with 21 additions and 20 deletions

View file

@ -3,6 +3,7 @@ include: package:flutter_lints/flutter.yaml
linter: linter:
rules: rules:
unawaited_futures: true unawaited_futures: true
avoid_void_async: true
depend_on_referenced_packages: false depend_on_referenced_packages: false
prefer_interpolation_to_compose_strings: false prefer_interpolation_to_compose_strings: false
no_leading_underscores_for_local_identifiers: false no_leading_underscores_for_local_identifiers: false

View file

@ -99,7 +99,7 @@ class MetadataTaskManager {
} }
} }
void _handleStream() async { Future<void> _handleStream() async {
await for (final task in _streamController.stream) { await for (final task in _streamController.stream) {
if (Pref().isEnableExifOr()) { if (Pref().isEnableExifOr()) {
_log.info("[_doTask] Executing task: $task"); _log.info("[_doTask] Executing task: $task");

View file

@ -54,7 +54,7 @@ void stopService() {
} }
@visibleForTesting @visibleForTesting
void serviceMain() async { Future<void> serviceMain() async {
_Service._shouldRun.value = true; _Service._shouldRun.value = true;
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();

View file

@ -362,7 +362,7 @@ class _AlbumBrowserState extends State<AlbumBrowser>
album: _album)); album: _album));
} }
void _onSharePressed(BuildContext context) async { Future<void> _onSharePressed(BuildContext context) async {
await _showSharedAlbumInfoDialog(); await _showSharedAlbumInfoDialog();
await showDialog( await showDialog(
context: context, context: context,

View file

@ -220,7 +220,7 @@ mixin AlbumBrowserMixin<T extends StatefulWidget>
} }
} }
void _onAddToCollectionPressed( Future<void> _onAddToCollectionPressed(
BuildContext context, Account account, Album album) async { BuildContext context, Account account, Album album) async {
Album? newAlbum; Album? newAlbum;
try { try {

View file

@ -216,7 +216,7 @@ class _AlbumImporterState extends State<AlbumImporter> {
} }
} }
void _onImportPressed(BuildContext context) async { Future<void> _onImportPressed(BuildContext context) async {
unawaited( unawaited(
showDialog( showDialog(
barrierDismissible: false, barrierDismissible: false,

View file

@ -424,7 +424,7 @@ class _DynamicAlbumBrowserState extends State<DynamicAlbumBrowser>
).shareFiles(widget.account, selected); ).shareFiles(widget.account, selected);
} }
void _onSelectionDeletePressed() async { Future<void> _onSelectionDeletePressed() async {
SnackBarManager().showSnackBar( SnackBarManager().showSnackBar(
SnackBar( SnackBar(
content: Text(L10n.global() content: Text(L10n.global()

View file

@ -437,7 +437,7 @@ class _HomeAlbumsState extends State<HomeAlbums>
); );
} }
void _onSortSelected(album_util.AlbumSort sort) async { Future<void> _onSortSelected(album_util.AlbumSort sort) async {
await Pref().setHomeAlbumsSort(sort.index); await Pref().setHomeAlbumsSort(sort.index);
setState(() { setState(() {
_transformItems(_bloc.state.items); _transformItems(_bloc.state.items);

View file

@ -421,7 +421,7 @@ class _PersonBrowserState extends State<PersonBrowser>
); );
} }
void _transformItems(List<Face> items) async { Future<void> _transformItems(List<Face> items) async {
final files = await PopulatePerson(_c)(widget.account, items); final files = await PopulatePerson(_c)(widget.account, items);
_backingFiles = files _backingFiles = files
.sorted(compareFileDateTimeDescending) .sorted(compareFileDateTimeDescending)

View file

@ -52,7 +52,7 @@ class _RootPickerState extends State<RootPicker> {
_initAccount(); _initAccount();
} }
void _initAccount() async { Future<void> _initAccount() async {
final c = KiwiContainer().resolve<DiContainer>(); final c = KiwiContainer().resolve<DiContainer>();
final files = <File>[]; final files = <File>[];
for (final r in widget.account.roots) { for (final r in widget.account.roots) {

View file

@ -397,7 +397,7 @@ class _SettingsState extends State<Settings> {
} }
} }
void _onCaptureLogChanged(BuildContext context, bool value) async { Future<void> _onCaptureLogChanged(BuildContext context, bool value) async {
if (value) { if (value) {
final result = await showDialog<bool>( final result = await showDialog<bool>(
context: context, context: context,
@ -1375,7 +1375,7 @@ class _ThemeSettingsState extends State<_ThemeSettings> {
); );
} }
void _onFollowSystemThemeChanged(bool value) async { Future<void> _onFollowSystemThemeChanged(bool value) async {
final oldValue = _isFollowSystemTheme; final oldValue = _isFollowSystemTheme;
setState(() { setState(() {
_isFollowSystemTheme = value; _isFollowSystemTheme = value;
@ -1394,7 +1394,7 @@ class _ThemeSettingsState extends State<_ThemeSettings> {
} }
} }
void _onUseBlackInDarkThemeChanged(BuildContext context, bool value) async { Future<void> _onUseBlackInDarkThemeChanged(BuildContext context, bool value) async {
final oldValue = _isUseBlackInDarkTheme; final oldValue = _isUseBlackInDarkTheme;
setState(() { setState(() {
_isUseBlackInDarkTheme = value; _isUseBlackInDarkTheme = value;
@ -1491,7 +1491,7 @@ class _MiscSettingsState extends State<_MiscSettings> {
} }
} }
void _onPhotosTabSortByNameChanged(bool value) async { Future<void> _onPhotosTabSortByNameChanged(bool value) async {
final oldValue = _isPhotosTabSortByName; final oldValue = _isPhotosTabSortByName;
setState(() { setState(() {
_isPhotosTabSortByName = value; _isPhotosTabSortByName = value;

View file

@ -239,7 +239,7 @@ class _SlideshowViewerState extends State<SlideshowViewer>
_setupSlideTransition(widget.startIndex); _setupSlideTransition(widget.startIndex);
} }
void _onSlideshowTick() async { Future<void> _onSlideshowTick() async {
if (!mounted) { if (!mounted) {
return; return;
} }

View file

@ -267,7 +267,7 @@ class _TrashbinBrowserState extends State<TrashbinBrowser>
} }
} }
void _onEmptyTrashPressed(BuildContext context) async { Future<void> _onEmptyTrashPressed(BuildContext context) async {
unawaited( unawaited(
showDialog( showDialog(
context: context, context: context,

View file

@ -156,7 +156,7 @@ class _TrashbinViewerState extends State<TrashbinViewer> {
); );
} }
void _onRestorePressed() async { Future<void> _onRestorePressed() async {
final file = widget.streamFiles[_viewerController.currentPage]; final file = widget.streamFiles[_viewerController.currentPage];
_log.info("[_onRestorePressed] Restoring file: ${file.path}"); _log.info("[_onRestorePressed] Restoring file: ${file.path}");
SnackBarManager().showSnackBar( SnackBarManager().showSnackBar(

View file

@ -93,7 +93,7 @@ class _VideoViewerState extends State<VideoViewer>
_controller.dispose(); _controller.dispose();
} }
void _initController(String url) async { Future<void> _initController(String url) async {
try { try {
_controller = VideoPlayerController.network( _controller = VideoPlayerController.network(
url, url,

View file

@ -612,7 +612,7 @@ class _ViewerState extends State<Viewer>
DownloadHandler().downloadFiles(widget.account, [file]); DownloadHandler().downloadFiles(widget.account, [file]);
} }
void _onDeletePressed(BuildContext context) async { Future<void> _onDeletePressed(BuildContext context) async {
final file = widget.streamFiles[_viewerController.currentPage]; final file = widget.streamFiles[_viewerController.currentPage];
_log.info("[_onDeletePressed] Removing file: ${file.path}"); _log.info("[_onDeletePressed] Removing file: ${file.path}");
final count = await RemoveSelectionHandler()( final count = await RemoveSelectionHandler()(
@ -626,7 +626,7 @@ class _ViewerState extends State<Viewer>
} }
} }
void _onSlideshowPressed() async { Future<void> _onSlideshowPressed() async {
final result = await showDialog<SlideshowConfig>( final result = await showDialog<SlideshowConfig>(
context: context, context: context,
builder: (_) => SlideshowDialog( builder: (_) => SlideshowDialog(

View file

@ -430,7 +430,7 @@ class _ViewerDetailPaneState extends State<ViewerDetailPane> {
} }
} }
void _onUnarchivePressed(BuildContext context) async { Future<void> _onUnarchivePressed(BuildContext context) async {
_log.info("[_onUnarchivePressed] Unarchive file: ${widget.file.path}"); _log.info("[_onUnarchivePressed] Unarchive file: ${widget.file.path}");
try { try {
await NotifiedAction( await NotifiedAction(