I try to catch a JavaScript error when playing a sound with audioplayers. The audioplayers function to play a sound does not throw an error but in the browser log i get Error: NotAllowedError: play() failed because the user didn't interact with the document first. https://developer.chrome.com/blog/autoplay/
. My IDE prints
Error: NotAllowedError: play() failed because the user didn't interact with the document first. https://developer.chrome.com/blog/autoplay/
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 299:10 createErrorWithStack
dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 355:28 _throw
dart-sdk/lib/core/errors.dart 120:5 throwWithStackTrace
dart-sdk/lib/async/zone.dart 1385:11 callback
dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 166:15 <fn>
I have tried following code which you can find in the flutter docs:
void main() {
FlutterError.onError = (details) {
FlutterError.presentError(details);
debugPrint("FlutterError");
};
PlatformDispatcher.instance.onError = (error, stack) {
debugPrint("PlatformDispatcher");
return true;
};
runApp(const MyApp());
}
However this code does not print anything. How can I catch JavaScript errors of js_dev_runtime?