Files: don't context.watch from the item tap handler

watch outside build asserts in debug builds, so taps on rows silently did
nothing in debug (release strips the assert, which hid it on Android).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Ayushya Amitabh
2026-10-05 22:13:45 -04:00
co-authored by Claude Sonnet 5.5
parent 52abd16983
commit d6448984d9
+12 -2
View File
@@ -245,9 +245,19 @@ class _FilesViewState extends State<FilesView> {
/// The folder data source for this tab. Watches the concrete controller /// The folder data source for this tab. Watches the concrete controller
/// (that's what's registered as a provider), then hands it back as the /// (that's what's registered as a provider), then hands it back as the
/// [FolderBrowser] the rest of the view actually needs. /// [FolderBrowser] the rest of the view actually needs.
FolderBrowser _browserOf(BuildContext context) => _offline ///
/// Pass `listen: false` from tap/gesture callbacks: `context.watch` outside
/// of `build` asserts in debug builds (silently swallowing the tap).
FolderBrowser _browserOf(BuildContext context, {bool listen = true}) {
if (listen) {
return _offline
? context.watch<OfflineController>() ? context.watch<OfflineController>()
: context.watch<FilesController>(); : context.watch<FilesController>();
}
return _offline
? context.read<OfflineController>()
: context.read<FilesController>();
}
/// The on-device copy of [item] for the Offline tab; null online, where /// The on-device copy of [item] for the Offline tab; null online, where
/// thumbnails come from server previews instead. /// thumbnails come from server previews instead.
@@ -287,7 +297,7 @@ class _FilesViewState extends State<FilesView> {
NextcloudItem item, { NextcloudItem item, {
required bool picking, required bool picking,
}) { }) {
final browser = _browserOf(context); final browser = _browserOf(context, listen: false);
if (picking) { if (picking) {
_handlePickTap(context, item); _handlePickTap(context, item);
} else if (_isSelecting) { } else if (_isSelecting) {