From a05efef3c8d707a938d7278a759f5a1f993e8880 Mon Sep 17 00:00:00 2001 From: edde746 <86283021+edde746@users.noreply.github.com> Date: Fri, 27 Mar 2026 10:39:50 +0100 Subject: [PATCH] fix: guard download action button focus node access --- lib/widgets/download_tree_view.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/widgets/download_tree_view.dart b/lib/widgets/download_tree_view.dart index 3e0af6e0..9a1f92b0 100644 --- a/lib/widgets/download_tree_view.dart +++ b/lib/widgets/download_tree_view.dart @@ -884,6 +884,17 @@ class _DownloadTreeItemState extends State<_DownloadTreeItem> { required VoidCallback onPressed, required int buttonIndex, }) { + // Guard against race condition where action count changed between didUpdateWidget and build + if (buttonIndex >= _buttonFocusNodes.length) { + return Tooltip( + message: tooltip, + child: GestureDetector( + onTap: onPressed, + child: Padding(padding: const EdgeInsets.all(8.0), child: AppIcon(icon, fill: 1, size: 20)), + ), + ); + } + final isFirst = buttonIndex == 0; final isLast = buttonIndex == _buttonFocusNodes.length - 1;