error handling for async calls
This commit is contained in:
@@ -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;
|
||||||
await (createSource(), calculateAspectRatio()).wait;
|
late final double? aspectRatioRes;
|
||||||
|
try {
|
||||||
|
(videoSourceRes, aspectRatioRes) =
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user