I have a Flutter app that can show YouTube videos inside WebView. It works ok, except in one case: if you open it fullscreen and that pres=s embedded "exit from fullscreen" button in YouTube player: after exiting from fullscreen I still hear the sound, but I see a black screen with button share and watch later. In case when I exit from fullscreen mode by pressing the android back button it works ok. Ho to fix it?
Widget build(BuildContext context) {
return Container(
child: MyWebView(
initUrl:
'https://www.youtube.com/embed/${id}?autoplay=1&rel=0&showinfo=0',
),
)
}
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
class MyWebView extends StatefulWidget {
final String initUrl;
MyWebView({
this.initUrl,
});
@override
MyWebViewState createState() => MyWebViewState();
}
class MyWebViewState extends State<MyWebView> {
InAppWebViewController webView;
String url;
bool webLoadError = false;
@override
void initState() {
url = widget.initUrl;
super.initState();
}
@override
Widget build(BuildContext context) {
return Stack(
children: [
InAppWebView(
initialUrl: url,
initialHeaders: widget.headers,
initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(
debuggingEnabled: true,
useShouldOverrideUrlLoading: true,
clearCache: true,
mediaPlaybackRequiresUserGesture: false,
),
),
onLoadStart: (controller, string) {
setState(() {
webView = controller;
webLoadError = false;
});
},
);
}
}