Flutter flutter_inappwebview rotate to landscape when the user click the fullscreen video. In the documentation flutter_inappwebview says.
onEnterFullscreen: Event fired when the current page has entered full screen mode.
onExitFullscreen: Event fired when the current page has exited full screen mode.
Container( height: globals.screenHeight * 0.25, color: Colors.white, child: Column(children: <Widget>[ Expanded( child: Container( margin: const EdgeInsets.all(0.0), decoration: BoxDecoration( border: Border.all(color: Colors.blueAccent)), child: InAppWebView( initialUrl: "http://URL/play.html?name=123456789", initialHeaders: {}, onWebViewCreated: (InAppWebViewController controller) { webView = controller; }, onEnterFullscreen: AutoOrientation.landscapeAutoMode(), onLoadStart: (InAppWebViewController controller, String url) { setState(() { this.url = url; }); }, onLoadStop: (InAppWebViewController controller, String url) async { setState(() { this.url = url; }); }, onProgressChanged: (InAppWebViewController controller, int progress) { setState(() { this.progress = progress / 100; }); }, ), ), ), ] ) ),
when the page load, the phone automatic landscape, and i received this error.
what i want is, when the user click the fullscreen, the video automatic landscape
The problem is that onEnterFullscreen
is waiting for a (InAppViewController) => void
but you are assigning the result of AutoOrientation.landscapeAutoMode()
.
onEnterFullscreen: AutoOrientation.landscapeAutoMode(),
So, that function is evaluated each time that build
method is called. That is the reason why you have those two weird behaviors:
To solve that, you need to assign the callback in this way:
onEnterFullscreen: (controller) { AutoOrientation.landscapeAutoMode() },
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.