Advertisement
chnzyn

flutter revive non-video ads

May 30th, 2025
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 2.45 KB | Source Code | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:webview_flutter/webview_flutter.dart';
  3. import 'package:url_launcher/url_launcher.dart';
  4.  
  5. void main() {
  6.   runApp(const MaterialApp(home: BannerAdPage()));
  7. }
  8.  
  9. class BannerAdPage extends StatelessWidget {
  10.   const BannerAdPage({super.key});
  11.  
  12.   Widget buildAdBanner({
  13.     required String zoneId,
  14.     required double width,
  15.     required double height,
  16.   }) {
  17.     final String htmlContent = '''
  18. <!DOCTYPE html>
  19. <html>
  20.  <head>
  21.    <meta name="viewport" content="width=device-width, initial-scale=1.0">
  22.    <style>
  23.      html, body {
  24.        margin: 0;
  25.        padding: 0;
  26.        background-color: white;
  27.        display: flex;
  28.        justify-content: center;
  29.        align-items: center;
  30.        height: 100%;
  31.        overflow: hidden;
  32.      }
  33.      iframe {
  34.        border: none;
  35.      }
  36.    </style>
  37.  </head>
  38.  <body>
  39.    <iframe
  40.      src="https://ads.orderi.co/www/delivery/afr.php?zoneid=$zoneId"
  41.      width="$width"
  42.      height="$height"
  43.      scrolling="no"
  44.      allow="autoplay">
  45.    </iframe>
  46.  </body>
  47. </html>
  48. ''';
  49.  
  50.     final controller = WebViewController()
  51.       ..setJavaScriptMode(JavaScriptMode.unrestricted)
  52.       ..setNavigationDelegate(
  53.         NavigationDelegate(
  54.           onNavigationRequest: (request) {
  55.             final url = request.url;
  56.             if (url.contains("ads.orderi.co")) {
  57.               return NavigationDecision.navigate;
  58.             } else {
  59.               launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication);
  60.               return NavigationDecision.prevent;
  61.             }
  62.           },
  63.         ),
  64.       )
  65.       ..loadHtmlString(htmlContent, baseUrl: "https://ads.orderi.co");
  66.  
  67.     return Padding(
  68.       padding: const EdgeInsets.symmetric(vertical: 10),
  69.       child: SizedBox(
  70.         width: width,
  71.         height: height,
  72.         child: WebViewWidget(controller: controller),
  73.       ),
  74.     );
  75.   }
  76.  
  77.   @override
  78.   Widget build(BuildContext context) {
  79.     return Scaffold(
  80.       appBar: AppBar(title: const Text('Non-Video Ad Banners')),
  81.       body: SingleChildScrollView(
  82.         child: Center(
  83.           child: Column(
  84.             children: [
  85.               buildAdBanner(zoneId: '6', width: 728, height: 90),
  86.               buildAdBanner(zoneId: '8', width: 349, height: 144),
  87.               buildAdBanner(zoneId: '10', width: 1000, height: 1000),
  88.             ],
  89.           ),
  90.         ),
  91.       ),
  92.     );
  93.   }
  94. }
  95.  
  96.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement