duyduong / flutter_native_admob

Plugin to integrate native firebase admob to Flutter application
MIT License
62 stars 85 forks source link

about numberAds parameter #68

Open zirho opened 4 years ago

zirho commented 4 years ago

Hi,

I'd like to ask about numberAds param. It's hard for me to figure out how to use it.

I thought it would cache 4 ads and show the cache with the index Isn't this how it's supposed to work? I put up my code below.

There are not much of docs or example around it.

Thanks for the awesome project.

import 'package:flutter/material.dart';
import 'package:flutter_native_admob/flutter_native_admob.dart';
import 'package:flutter_native_admob/native_admob_controller.dart';

class AdmobPage4 extends StatefulWidget {
  @override
  _AdmobPage4State createState() => _AdmobPage4State();
}

class _AdmobPage4State extends State<AdmobPage4> {
  static const _adUnitID = "ca-app-pub-5046562646162404/5259802678";

  NativeAdmobController _nativeAdController;

  @override
  void initState() {
    _nativeAdController = NativeAdmobController();
    _nativeAdController.setAdUnitID(_adUnitID, numberAds: 4);
    _nativeAdController.setTestDeviceIds(["C3F8FA9E55B3AE3C8D581B59F724E8B0"]);

    super.initState();
  }

  @override
  void dispose() {
    _nativeAdController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: ListView.builder(
          itemCount: 200,
          itemBuilder: (context, index) {
            if (index % 2 == 0) {
              int idx = (index / 2).floor();
              return Container(
                height: 330,
                padding: EdgeInsets.all(10),
                margin: EdgeInsets.only(bottom: 20.0),
                child: NativeAdmob(
                  numberAds: idx,
                  loading: Container(color: Colors.red),
                  adUnitID: _adUnitID,
                  controller: _nativeAdController,
                ),
              );
            }
            return Container(
              margin: EdgeInsets.only(bottom: 20.0),
              height: 200.0,
              color: Colors.green,
            );
          },
        ),
      ),
    );
  }
}
tahercoolguy commented 4 years ago

Hey Did you get your answer. Because I am also didn't able to get what this numberAds do.

zirho commented 4 years ago

not really. I don't think it works properly. should we reopen and get some answers?

tahercoolguy commented 4 years ago

Yes please reopened it because I want to show different ads on each impression

armandojimenez commented 3 years ago

any update on this?