Adblocker for Flutter Webview

Viewed 350

I have made an app using the webview_flutter plugin, the webviews leads to a url that streams a video. But there's a new advertisement pop-up everytime I enter this webview. I'd be glad if anyone could provide a solution to prevent this from happening. I have added the code here, and I'm using NavigationDecision.prevent to disable the ads from taking me to a new page.

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;
      } ,

    );
  }
}
0 Answers
Related