This commit is contained in:
Thibault Deckers 2023-01-24 20:15:01 +01:00
parent 8ce8eb8c71
commit 3ff87f3b4f
4 changed files with 59 additions and 24 deletions

View file

@ -36,9 +36,7 @@ class PlatformMetadataEditService implements MetadataEditService {
}); });
if (result != null) return (result as Map).cast<String, dynamic>(); if (result != null) return (result as Map).cast<String, dynamic>();
} on PlatformException catch (e, stack) { } on PlatformException catch (e, stack) {
if (!entry.isMissingAtPath) { await _processPlatformException(entry, e, stack);
await reportService.recordError(e, stack);
}
} }
return {}; return {};
} }
@ -52,9 +50,7 @@ class PlatformMetadataEditService implements MetadataEditService {
}); });
if (result != null) return (result as Map).cast<String, dynamic>(); if (result != null) return (result as Map).cast<String, dynamic>();
} on PlatformException catch (e, stack) { } on PlatformException catch (e, stack) {
if (!entry.isMissingAtPath) { await _processPlatformException(entry, e, stack);
await reportService.recordError(e, stack);
}
} }
return {}; return {};
} }
@ -70,9 +66,7 @@ class PlatformMetadataEditService implements MetadataEditService {
}); });
if (result != null) return (result as Map).cast<String, dynamic>(); if (result != null) return (result as Map).cast<String, dynamic>();
} on PlatformException catch (e, stack) { } on PlatformException catch (e, stack) {
if (!entry.isMissingAtPath) { await _processPlatformException(entry, e, stack);
await reportService.recordError(e, stack);
}
} }
return {}; return {};
} }
@ -91,9 +85,7 @@ class PlatformMetadataEditService implements MetadataEditService {
}); });
if (result != null) return (result as Map).cast<String, dynamic>(); if (result != null) return (result as Map).cast<String, dynamic>();
} on PlatformException catch (e, stack) { } on PlatformException catch (e, stack) {
if (!entry.isMissingAtPath) { await _processPlatformException(entry, e, stack);
await reportService.recordError(e, stack);
}
} }
return {}; return {};
} }
@ -106,9 +98,7 @@ class PlatformMetadataEditService implements MetadataEditService {
}); });
if (result != null) return (result as Map).cast<String, dynamic>(); if (result != null) return (result as Map).cast<String, dynamic>();
} on PlatformException catch (e, stack) { } on PlatformException catch (e, stack) {
if (!entry.isMissingAtPath) { await _processPlatformException(entry, e, stack);
await reportService.recordError(e, stack);
}
} }
return {}; return {};
} }
@ -122,10 +112,52 @@ class PlatformMetadataEditService implements MetadataEditService {
}); });
if (result != null) return (result as Map).cast<String, dynamic>(); if (result != null) return (result as Map).cast<String, dynamic>();
} on PlatformException catch (e, stack) { } on PlatformException catch (e, stack) {
if (!entry.isMissingAtPath) { await _processPlatformException(entry, e, stack);
await reportService.recordError(e, stack);
}
} }
return {}; return {};
} }
Future<void> _processPlatformException(AvesEntry entry, PlatformException e, StackTrace stack) async {
if (!entry.isMissingAtPath) {
final code = e.code;
if (code.endsWith('mp4largemoov')) {
await reportService.recordError(_Mp4LargeMoovException(code: e.code, message: e.message, details: e.details, stacktrace: e.stacktrace), stack);
} else if (code.endsWith('mp4largeother')) {
await reportService.recordError(_Mp4LargeOtherException(code: e.code, message: e.message, details: e.details, stacktrace: e.stacktrace), stack);
} else if (code.endsWith('filenotfound')) {
await reportService.recordError(_FileNotFoundException(code: e.code, message: e.message, details: e.details, stacktrace: e.stacktrace), stack);
} else {
await reportService.recordError(e, stack);
}
}
}
}
// distinct exceptions to convince Crashlytics to split reports into distinct issues
class _Mp4LargeMoovException extends PlatformException {
_Mp4LargeMoovException({
required super.code,
required super.message,
required super.details,
required super.stacktrace,
});
}
class _Mp4LargeOtherException extends PlatformException {
_Mp4LargeOtherException({
required super.code,
required super.message,
required super.details,
required super.stacktrace,
});
}
class _FileNotFoundException extends PlatformException {
_FileNotFoundException({
required super.code,
required super.message,
required super.details,
required super.stacktrace,
});
} }

View file

@ -336,11 +336,14 @@ class _EntryPageViewState extends State<EntryPageView> with SingleTickerProvider
], ],
); );
if (useVerticalDragGesture) { if (useVerticalDragGesture) {
videoChild = MagnifierGestureDetectorScope.of(context)!.copyWith( final scope = MagnifierGestureDetectorScope.maybeOf(context);
if (scope != null) {
videoChild = scope.copyWith(
acceptPointerEvent: MagnifierGestureRecognizer.isYPan, acceptPointerEvent: MagnifierGestureRecognizer.isYPan,
child: videoChild, child: videoChild,
); );
} }
}
return Stack( return Stack(
fit: StackFit.expand, fit: StackFit.expand,
children: [ children: [

View file

@ -54,7 +54,7 @@ class _MagnifierGestureDetectorState extends State<MagnifierGestureDetector> {
); );
} }
final scope = MagnifierGestureDetectorScope.of(context); final scope = MagnifierGestureDetectorScope.maybeOf(context);
if (scope != null) { if (scope != null) {
gestures[MagnifierGestureRecognizer] = GestureRecognizerFactoryWithHandlers<MagnifierGestureRecognizer>( gestures[MagnifierGestureRecognizer] = GestureRecognizerFactoryWithHandlers<MagnifierGestureRecognizer>(
() => MagnifierGestureRecognizer( () => MagnifierGestureRecognizer(

View file

@ -24,7 +24,7 @@ class MagnifierGestureDetectorScope extends InheritedWidget {
required Widget child, required Widget child,
}) : super(child: child); }) : super(child: child);
static MagnifierGestureDetectorScope? of(BuildContext context) { static MagnifierGestureDetectorScope? maybeOf(BuildContext context) {
return context.dependOnInheritedWidgetOfExactType<MagnifierGestureDetectorScope>(); return context.dependOnInheritedWidgetOfExactType<MagnifierGestureDetectorScope>();
} }