Gau*_*ham 5 adsense flutter flutter-web
我制作了一个 320 像素 * 60 像素的固定展示广告。如何在我想要的地方插入颤振网络?这是我从adsense获得的代码:
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- MyAd -->
<ins class="adsbygoogle"
style="display:inline-block;width:320px;height:60px"
data-ad-client="xxxxxxxxx"
data-ad-slot="xxxxxxxx"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
Run Code Online (Sandbox Code Playgroud)
或者是否有可能通过以某种方式操纵 flt-glass-pane 使 flutter 不占据屏幕底部 60 像素并在那里插入 AdSense 广告?
我正在寻找一种将 AdSense 广告插入到内置 flutter-web 的移动网站的方法
我能够将广告插入到 flutter-web 中的列表视图中,如下所示:创建了一个 html 文件 adview.html
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:inline-block;width:320px;height:80px"
data-ad-client="ca-pub-xxxxxx"
data-ad-slot="xxxxxxx"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
Run Code Online (Sandbox Code Playgroud)
然后,一个 IFrameElement 使用 html:
// ignore: avoid_web_libraries_in_flutter
import 'dart:html';
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
Widget adsenseAdsView() {
// ignore: undefined_prefixed_name
ui.platformViewRegistry.registerViewFactory(
'adViewType',
(int viewID) => IFrameElement()
..width = '320'
..height = '100'
..src = 'adview.html'
..style.border = 'none');
return SizedBox(
height: 100.0,
width: 320.0,
child: HtmlElementView(
viewType: 'adViewType',
),
);
}
Run Code Online (Sandbox Code Playgroud)
然后我们可以在我们想要的任何地方从函数 adsenseAdsView() 添加小部件。我把它添加到ListView中。
归档时间: |
|
查看次数: |
1037 次 |
最近记录: |