android - Flutter Webview 的广告拦截器
问题描述
我使用 webview_flutter 插件制作了一个应用程序,webviews 指向一个流式传输视频的 url。但是每次我进入这个网页视图时都会弹出一个新的广告。如果有人能提供解决方案来防止这种情况发生,我会很高兴。我在此处添加了代码,并且正在使用 NavigationDecision.prevent 来禁止广告将我带到新页面。
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
class WebViewExample extends StatefulWidget {
@override
WebViewExampleState createState() => WebViewExampleState();
}
class WebViewExampleState extends State<WebViewExample> {
@override
void initState() {
super.initState();
if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView();
}
@override
Widget build(BuildContext context) {
return WebView(
initialUrl: "https://streamani.net/streaming.php?id=MTA4NjM4&title=Boruto%3A+Naruto+Next+Generations&typesub=SUB&sub=&cover=Y292ZXIvYm9ydXRvLW5hcnV0by1uZXh0LWdlbmVyYXRpb25zLnBuZw==",
javascriptMode: JavascriptMode.unrestricted,
navigationDelegate: (NavigationRequest request) {
return NavigationDecision.prevent;
} ,
);
}
}
解决方案
推荐阅读
- javascript - How to import a class method into a React class
- ios - 我是否必须更新我的 iphone(到最新版本)才能将其与最新版本的 xcode 连接?
- r - 在 r 中绘制拟合线
- php - 如何使用php codeigniter解析csv数据并插入数据库
- jquery - jquery css的负边距
- java - 发送密钥在 selenium java 中不起作用
- java - 注释未调用 AOP
- php - PHP发送邮件错误:标题必须是一个数组
- c++ - 如何在 wxWidgets 中使用多线程?
- java - bufferedWriter 是否需要 getter