我使用flutter_webview_plugin在应用程序中显示网页,但是当页面上有视频时,没有启用全屏的选项。有谁知道如何解决这个问题? 也许还有其他插件可以在应用程序中显示页面?
import 'package:flutter/material.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
String url = "https://youtube.com/";
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Webview Example',
theme: ThemeData.dark(),
routes: {
"/": (_) => Home(),
"/webview": (_) => WebviewScaffold(
url: url,
appBar: AppBar(
title: Text("WebView"),
),
withJavascript: true,
withLocalStorage: true,
withZoom: true,
)
},
);
}
}
//Rest of the code
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("WebView"),
),
body: Center(
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.all(10.0),
child: TextField(
controller: controller,
),
),
RaisedButton(
child: Text("Open Webview"),
onPressed: () {
Navigator.of(context).pushNamed("/webview");
},
)
],
),
)
);
}
}
答案 0 :(得分:0)
您可以尝试使用我的插件flutter_inappbrowser(编辑:它已重命名为flutter_inappwebview)。
下面是一个带有youtube视频的示例:
...
child: InAppWebView(
initialUrl: "https://www.youtube.com/watch?v=sPW7nDBqt8w",
initialHeaders: {},
initialOptions: InAppWebViewWidgetOptions(
inAppWebViewOptions: InAppWebViewOptions(
debuggingEnabled: true,
)
),
onWebViewCreated: (InAppWebViewController controller) {
webView = controller;
},
onLoadStart: (InAppWebViewController controller, String url) {
},
onLoadStop: (InAppWebViewController controller, String url) {
},
),
...