问题描述
我想在我的Flutter应用程序中隐藏网站的部分。我在pubspec.yaml文件中添加了Flutter Flutter_webview_plugin,并将包导入了我的Feed.dart页面。当我运行应用程序时,将执行FlutterWebviewPlugin.evalJavascript("alert('Hi,I just executed')");
。但是FlutterWebviewPlugin.evalJavascript("document.getElementById('header04-2j').style.display = 'none';");
我试图隐藏标题,但无法正常工作。下面是源代码。
class FeedPage extends StatefulWidget {
@override
FeedPageState createState() {
return new FeedPageState();
}
}
class FeedPageState extends State<FeedPage> {
final FlutterWebviewPlugin = new FlutterWebviewPlugin();
// alternatively you can define variable as var js = "YOUR_SCRIPT"; and use it inside evalJavascript
@override
void initState(){
super.initState();
FlutterWebviewPlugin.evalJavascript("alert('Hi,I just executed')"); // executed
FlutterWebviewPlugin.evalJavascript("document.getElementById('header04-2j').style.display = 'none';"); // not executed
}
@override
void dispose() {
FlutterWebviewPlugin.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return WebviewScaffold(
url: 'https://www.esdatech.com/',hidden: true,appBar: AppBar(title: Text("ESDA")),);
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)