-
Notifications
You must be signed in to change notification settings - Fork 998
Description
Is there an existing issue for this?
- I have searched the existing issues
Package
youtube_player_flutter
What happened?
When loading a YouTube video with an invalid ID using youtube_player_flutter, I see this error in the
Uncaught Error: Invalid video id
However, neither:
youtubeController.addListener(() { ... });
nor controller.value.hasError captures this error.
Attempts to access the underlying WebView controller (e.g., setWebViewClient) do not work because those methods are not exposed in Flutter.
As a result, there is no way to detect or show the user that the video failed to load due to an invalid video ID.
What is the expected behaviour?
I expect youtube_player_flutter to provide a way to capture JS console errors from the underlying WebView, so that the app can:
Detect invalid video IDs
Detect network/SSL errors
Show a proper error message to the user
Either through controller.value.hasError, a dedicated callback, or access to WebView console messages.
How to reproduce?
- Create a Flutter project with youtube_player_flutter.
- Initialize a YoutubePlayerController with an invalid video ID, e.g.:
YoutubePlayerController(
initialVideoId: "INVALID_ID",
flags: YoutubePlayerFlags(autoPlay: true),
);
- Run the app and observe the console.
- Try using controller.addListener or checking controller.value.hasError — the error is not detected in Flutter.
Flutter Doctor Output
[✓] Flutter (Channel stable, 3.38.6, on macOS 26.1 25B78 darwin-arm64, locale en-TR) [560ms]
• Flutter version 3.38.6 on channel stable at /Volumes/Media/Development/Flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 8b87286849 (3 weeks ago), 2026-01-08 10:49:17 -0800
• Engine revision 78fc3012e4
• Dart version 3.10.7
• DevTools version 2.51.1
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android,
enable-ios, cli-animations, enable-native-assets, omit-legacy-version-file, enable-lldb-debugging
[✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0) [2.4s]
• Android SDK at /Volumes/Media/Development/Android/sdk
• Emulator version 36.3.10.0 (build_id 14472402) (CL:N/A)
• Platform android-36, build-tools 36.1.0
• ANDROID_SDK_ROOT = /Volumes/Media/Development/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 21.0.8+-14196175-b1038.72)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 26.2) [1,687ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 17C52
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [7ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Connected device (6 available) [6.2s]
• sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 16 (API 36)
(emulator)
• iPhone 16 Pro (mobile) • A65A202B-EF2E-4967-A1BB-0B09F1C666B6 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-18-6 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 26.1 25B78
darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome
144.0.7559.110
[✓] Network resources [788ms]
• All expected network resources are available.
• No issues found!