我创建了一个320px *60px的固定显示广告。如何在flutter web中插入我想要的位置?这是我从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>或者,有没有可能让flutter不占据屏幕的底部60个像素,并通过某种方式操纵flt-glass-pane在那里插入adsense广告?
我正在寻找一种方法来插入adsense广告到一个内置在flutter web中的移动网站
发布于 2020-09-21 15:10:36
我能够在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>然后,使用该html的IFrameElement:
// 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',
),
);
}然后,我们可以从函数adsenseAdsView()中添加小部件。我在ListView中添加的。
https://stackoverflow.com/questions/63985740
复制相似问题