error handling for async calls

This commit is contained in:
mertalev 2024-11-16 20:57:42 -05:00
parent 6c8f7b7e6d
commit 71e058af2e
No known key found for this signature in database
GPG Key ID: CA85EF6600C9E8AD

View File

@ -65,7 +65,7 @@ class NativeVideoViewerPage extends HookConsumerWidget {
final log = Logger('NativeVideoViewerPage'); final log = Logger('NativeVideoViewerPage');
final localEntity = useMemoized(() { final localEntity = useMemoized(() {
if (!asset.isLocal) { if (!asset.isLocal || asset.isMotionPhoto) {
return null; return null;
} }
@ -116,7 +116,7 @@ class NativeVideoViewerPage extends HookConsumerWidget {
return null; return null;
} }
if (localEntity != null && asset.livePhotoVideoId == null) { if (localEntity != null) {
final file = await (await localEntity)!.file; final file = await (await localEntity)!.file;
if (file == null) { if (file == null) {
throw Exception('No file found for the video'); throw Exception('No file found for the video');
@ -151,8 +151,18 @@ class NativeVideoViewerPage extends HookConsumerWidget {
return null; return null;
} }
final (videoSourceRes, aspectRatioRes) = late final VideoSource? videoSourceRes;
late final double? aspectRatioRes;
try {
(videoSourceRes, aspectRatioRes) =
await (createSource(), calculateAspectRatio()).wait; await (createSource(), calculateAspectRatio()).wait;
} catch (error) {
log.severe(
'Error initializing video for asset ${asset.fileName}: $error',
);
return;
}
if (videoSourceRes == null || aspectRatioRes == null) { if (videoSourceRes == null || aspectRatioRes == null) {
return; return;
} }