Q: How to insert Adsense display ad in flutter web I created a fixed display ad 320px *60px. How do I insert in flutter web where I want?
This is the code I obtained from 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>

Or is it possible to make flutter not occupy the bottom 60 pixels of the screen and insert the adsense ad there by manipulating flt-glass-pane somehow?
I'm looking at a way to insert adsense ads to a mobile website built in flutter-web

A: I was able to insert ads into the listview in flutter-web as below:
Created an html file 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>

And then, an IFrameElement to make use of the 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',
    ),
  );
}

Then we can add the widget from the function adsenseAdsView() wherever we want. I added it in ListView.

A: There is a new package that can help with this. Hopefully makes the process a little simpler.
https://pub.dev/packages/admanager_web
Example to implement:
AdBlock(
 size: AdBlockSize.largeRectangle,
 adUnitId: "/6355419/Travel/Europe",) 


A: You can add Adsense ad unit In Flutter Web with the help of below widget. It's work perfectly fine.
create widget with any name you like. I'm name BannerAdUnit
only replace div tag ad unit id and script add Url as you can see in the below widget inside html body tag.
import 'dart:html' as html;  
import 'dart:ui' as ui;  
  
import 'package:flutter/material.dart';  
  
String viewID = "your-view-id";  
  
class BannerAdUnit extends StatelessWidget {  
  const BannerAdUnit({Key? key}) : super(key: key);  
  
  @override  
  Widget build(BuildContext context) {  
  ui.platformViewRegistry.registerViewFactory(  
  viewID,  
  (int id) => html.IFrameElement()  
  ..style.width = '100%'  
  ..style.height = '100%'  
  ..srcdoc = '''  
        <!DOCTYPE html>  
 <html> <head> </head> <body>             
                     <div data-frill-widget="your ad unit id will come here" style="width: 340px; height: 460px;"></div>  
 <script async src="url"></script>           </body>  
 </html>           '''  
  ..style.border = 'none');  
  
  return SizedBox(  
  height: 460,  
  width: 340,  
  child: HtmlElementView(  
  viewType: viewID,  
  ),  
  );  
  }  
}

The story is not end here. When you add the above code You will see one beautiful error something like that.

The name 'platformViewRegistry' is being referenced through the prefix
'ui', but it isn't defined in any of the libraries imported using that
prefix. (Documentation)

How to fix this error? Don't worry I'll show you how to fix this error.
Create new file on the root name it analysis_options.yaml
and copy and paste the below code and the error is gone.
analyzer:
  errors:
    undefined_prefixed_name: ignore

Note: On the debugging mode flutter Web app not show you any ads.
if you want to see ads deploy your Flutter Web App. you will see ads like this.

If you guys don't want to write these spaghetti code try this package flutter_ad_manager_web. I created this helpful package for display Adsense ads on Flutter Web.
