Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:webview_flutter/webview_flutter.dart';
- import 'package:url_launcher/url_launcher.dart';
- void main() {
- runApp(const MaterialApp(home: BannerAdPage()));
- }
- class BannerAdPage extends StatelessWidget {
- const BannerAdPage({super.key});
- Widget buildAdBanner({
- required String zoneId,
- required double width,
- required double height,
- }) {
- final String htmlContent = '''
- <!DOCTYPE html>
- <html>
- <head>
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <style>
- html, body {
- margin: 0;
- padding: 0;
- background-color: white;
- display: flex;
- justify-content: center;
- align-items: center;
- height: 100%;
- overflow: hidden;
- }
- iframe {
- border: none;
- }
- </style>
- </head>
- <body>
- <iframe
- src="https://ads.orderi.co/www/delivery/afr.php?zoneid=$zoneId"
- width="$width"
- height="$height"
- scrolling="no"
- allow="autoplay">
- </iframe>
- </body>
- </html>
- ''';
- final controller = WebViewController()
- ..setJavaScriptMode(JavaScriptMode.unrestricted)
- ..setNavigationDelegate(
- NavigationDelegate(
- onNavigationRequest: (request) {
- final url = request.url;
- if (url.contains("ads.orderi.co")) {
- return NavigationDecision.navigate;
- } else {
- launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication);
- return NavigationDecision.prevent;
- }
- },
- ),
- )
- ..loadHtmlString(htmlContent, baseUrl: "https://ads.orderi.co");
- return Padding(
- padding: const EdgeInsets.symmetric(vertical: 10),
- child: SizedBox(
- width: width,
- height: height,
- child: WebViewWidget(controller: controller),
- ),
- );
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(title: const Text('Non-Video Ad Banners')),
- body: SingleChildScrollView(
- child: Center(
- child: Column(
- children: [
- buildAdBanner(zoneId: '6', width: 728, height: 90),
- buildAdBanner(zoneId: '8', width: 349, height: 144),
- buildAdBanner(zoneId: '10', width: 1000, height: 1000),
- ],
- ),
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement