fix(mobile): video player using ref after disposal (#21843)

check if disposed
This commit is contained in:
Mert 2025-10-06 12:20:30 -04:00 committed by GitHub
parent 55ad83d80d
commit 43b06a036d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -88,10 +88,18 @@ class NativeVideoViewer extends HookConsumerWidget {
}
final videoAsset = await ref.read(assetServiceProvider).getAsset(asset) ?? asset;
if (!context.mounted) {
return null;
}
try {
if (videoAsset.hasLocal && videoAsset.livePhotoVideoId == null) {
final id = videoAsset is LocalAsset ? videoAsset.id : (videoAsset as RemoteAsset).localId!;
final file = await const StorageRepository().getFileForAsset(id);
if (!context.mounted) {
return null;
}
if (file == null) {
throw Exception('No file found for the video');
}
@ -289,7 +297,7 @@ class NativeVideoViewer extends HookConsumerWidget {
ref.read(videoPlaybackValueProvider.notifier).reset();
final source = await videoSource;
if (source == null) {
if (source == null || !context.mounted) {
return;
}