From 595ddf80356c7a39681a2e9eb29a79bf253bcce2 Mon Sep 17 00:00:00 2001 From: Garrett Watson Date: Mon, 13 Nov 2023 12:39:30 -0500 Subject: [PATCH] chore: address use of then method on awaited future --- .../inventory/inventory_browser_app_bar.dart | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/lib/widgets/inventory/inventory_browser_app_bar.dart b/lib/widgets/inventory/inventory_browser_app_bar.dart index 93eab10..2a79a63 100644 --- a/lib/widgets/inventory/inventory_browser_app_bar.dart +++ b/lib/widgets/inventory/inventory_browser_app_bar.dart @@ -243,23 +243,22 @@ class _InventoryBrowserAppBarState extends State { filename: filename, updates: Updates.statusAndProgress, ); - await FileDownloader().enqueue(downloadTask).then((b) { - if (context.mounted) { - if (b) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text("Downloaded ${record.formattedName.toString()}"), - ), - ); - } else { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text("Failed to download ${record.formattedName.toString()}"), - ), - ); - } + final downloadStatus = await FileDownloader().enqueue(downloadTask); + if (context.mounted) { + if (downloadStatus) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text("Downloaded ${record.formattedName.toString()}"), + ), + ); + } else { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text("Failed to download ${record.formattedName.toString()}"), + ), + ); } - }); + } final tempDirectory = await _tempDirectoryFuture; final file = File( "${tempDirectory.path}/${record.id.split("-")[1]}-${record.formattedName.toString()}${extension(uri)}");