搜索插件、代码仓与 APP 分类

插件详情v26.3.13

easy_ads_flutter

Easy Ads 是一个流行的广告包的包装器,可让您轻松集成广告

AndroidiOS
近 30 天下载
246
喜欢数
126
Pub 分数
150

安装插件

flutter pub add easy_ads_flutter

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Easy Ads Flutter 是一个流行的广告集成包的包装器,简化了在 Android 和 iOS 上的 Flutter 应用中添加广告的过程。它抽象了复杂的配置,并提供了一个统一且易于使用的接口,用于实现横幅广告、插屏广告和激励广告。专为希望无需深入了解广告 SDK 即可快速可靠地 monetize 其应用程序的开发者设计,它减少了样板代码并简化了设置流程。该包通过一致的 API 支持主要广告网络,使跨平台广告管理高效且易于访问。

适合场景

  • 通过应用内广告实现移动应用变现
  • 简化跨平台广告集成
  • 快速添加横幅、插页和激励视频广告
  • 通过广告功能实现快速原型设计
  • 通过一个界面管理多个广告网络

主要特点

  • 统一的广告API,适用于多个网络
  • 支持横幅广告、插屏广告和激励广告
  • 最小化设置和配置
  • 跨平台兼容性(Android 和 iOS)
  • 内置错误处理和回退

适合对象

  • Flutter 开发者新手入门广告集成
  • 需要快速实现广告的应用程序
  • 使用多个广告提供商的项目
  • 寻求减少样板代码的开发者
  • 专注于变现速度的初创企业

使用建议

  • 依赖于底层广告SDK以实现完整功能
  • 与直接使用 SDK 相比,自定义选项有限
  • 可能需要为高级广告设置进行额外配置
  • 不太适合高度专业化的广告工作流程
  • 需要遵守广告网络政策

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Easy Ads Flutter

pub package Last Commits Pull Requests Code size License PayPal

Show some 💙, 👍 the package & ⭐️ the repo to support the project

A plugin to easily integrate AdMob ads into your Flutter app.


⚠ Note

From version 26.3.12, this package supports AdMob only.

If you need Facebook, AppLovin, or Unity ads, you can use the alternative branches:

  • All Ad Networks (AdMob + Facebook + AppLovin + Unity)
    https://github.com/nooralibutt/easy-ads/tree/feature/all-ads-support

  • AdMob + Facebook Only
    https://github.com/nooralibutt/easy-ads/tree/feature/admob-facebook


New Feature: autoLoadAds

We've introduced a new autoLoadAds field in EasyAds initialization:

  • Purpose: Control whether ads are loaded automatically or not.
  • Default: true (ads are loaded automatically on initialization)
  • Usage:
    await EasyAds.instance.initialize(
      adIdManager,
      autoLoadAds: false, // disables automatic ad loading
    );```
    
    

If set to false, ads will not be loaded automatically. You must manually load ads using:

EasyAds.instance.loadAd(adUnitType: AdUnitType.interstitial);

Features

  • Google Mobile Ads (Banner, Native, App Open, Interstitial, Rewarded)
  • JIT (Just-in-Time) ad loading for Interstitial, App Open, and Rewarded ads
  • Simple API for loading and displaying ads
  • Event callbacks for ad lifecycle handling

AdMob Mediation

This plugin supports AdMob Mediation.

You can configure additional ad networks directly in your AdMob dashboard while still using this plugin.

See the official guide:
https://developers.google.com/admob/flutter/mediation/get-started


GDPR and Privacy Options Compliance

A Consent Manager helper is provided to support GDPR and privacy dialogs. ConsentManager.gatherGdprConsent() and ConsentManager.gatherPrivacyConsent()

Platform Specific Setup

iOS
Update your Info.plist
  • The Google Mobile Ads App ID is required in your Info.plist.

Update your app's ios/Runner/Info.plist file to add two keys:

<key>GADApplicationIdentifier</key>
<string>YOUR_SDK_KEY</string>
  • You have to add SKAdNetworkItems for all networks provided by easy-ads-flutter info.plist you can copy paste SKAdNetworkItems in your own project.
Android
Update AndroidManifest.xml
<manifest>
    <application>
        <!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
    </application>
</manifest>

Initialize Ad Ids

import 'dart:io';
import 'package:easy_ads_flutter/easy_ads_flutter.dart';

class TestAdIdManager extends IAdIdManager {
  const TestAdIdManager();

  @override
  AppAdIds? get admobAdIds => AppAdIds(
    appId: Platform.isAndroid
        ? 'ca-app-pub-3940256099942544~3347511713'
        : 'ca-app-pub-3940256099942544~1458002511',
    appOpenId: Platform.isAndroid
        ? 'ca-app-pub-3940256099942544/9257395921'
        : 'ca-app-pub-3940256099942544/5575463023',
    bannerId: Platform.isAndroid
        ? 'ca-app-pub-3940256099942544/9214589741'
        : 'ca-app-pub-3940256099942544/2435281174',
    interstitialId: Platform.isAndroid
        ? 'ca-app-pub-3940256099942544/1033173712'
        : 'ca-app-pub-3940256099942544/4411468910',
    rewardedId: Platform.isAndroid
        ? 'ca-app-pub-3940256099942544/5224354917'
        : 'ca-app-pub-3940256099942544/1712485313',
    nativeBannerId: Platform.isAndroid
        ? 'ca-app-pub-3940256099942544/2247696110'
        : 'ca-app-pub-3940256099942544/3986624511',
  );
}

Initialize the SDK

Before loading ads, have your app initialize the Mobile Ads SDK by calling EasyAds.instance.initialize() which initializes the SDK and returns a Future that finishes once initialization is complete (or after a 30-second timeout). This needs to be done only once, ideally right before running the app.

import 'package:easy_ads_flutter/easy_ads_flutter.dart';
import 'package:flutter/material.dart';

const IAdIdManager adIdManager = TestAdIdManager();

EasyAds.instance.initialize(
    adIdManager,
    adMobAdRequest: const AdRequest(),
    admobConfiguration: RequestConfiguration(testDeviceIds: [
      '072D2F3992EF5B4493042ADC632CE39F', // Mi Phone
      '00008030-00163022226A802E',
    ]),
  );

Interstitial/Rewarded Ads

Load an ad

Ad is automatically loaded after being displayed or first time when you call initialize. But on safe side, you can call this method. This will load both rewarded and interstitial ads. If a particular ad is already loaded, it will not load it again.

EasyAds.instance.loadAd();
Show interstitial or rewarded ad
EasyAds.instance.showAd(AdUnitType.rewarded);
Show appOpen ad
EasyAds.instance.showAd(AdUnitType.appOpen)

Show Banner Ads

This is how you may show banner ad in widget-tree somewhere:

@override
Widget build(BuildContext context) {
  Column(
    crossAxisAlignment: CrossAxisAlignment.stretch,
    children: [
      SomeWidget(),
      const Spacer(),
      EasyBannerAd(adSize: AdSize.largeBanner),
    ],
  );
}

JIT (Just-in-Time) Ads

This package supports JIT (Just-in-Time) ad loading for Interstitial, App Open, and Rewarded ads.
You can show ads on demand, with callbacks for success, failure, and dismissal.

Show JIT App Open
EasyAds.instance.showJitAppOpen(
  onFailedToLoadOrShow: () => _showSnack('AppOpen failed'),
  onAdShowed: () => _showSnack('AppOpen showed'),
  onAdDismissed: () => _showSnack('AppOpen dismissed'),
);
Show JIT Interstitial
EasyAds.instance.showJitInterstitial(
context,
onFailedToLoadOrShow: () => _showSnack('Interstitial failed'),
onAdShowed: () => _showSnack('Interstitial showed'),
onAdDismissed: () => _showSnack('Interstitial dismissed'),
);
Show JIT Rewarded
EasyAds.instance.showJitRewarded(
context,
onEarnedReward: (ctx) => _showSnack('Reward earned!'),
);
Native Ads

You can also create Native Ads and insert them into your widget tree using:

EasyAds.instance.createNativeAd();

Example usage in a widget tree:

@override
Widget build(BuildContext context) {
  return Column(
    children: [
      SomeWidget(),
      EasyAds.instance.createNativeAd(),
      AnotherWidget(),
    ],
  );
}

This ensures native ads are properly loaded and displayed within your UI.

Listening to the callbacks

Declare this object in the class

  StreamSubscription? _streamSubscription;

We are showing InterstitialAd here and also checking if ad has been shown. If true, we are canceling the subscribed callbacks, if any. Then, we are listening to the Stream and accessing the particular event we need

if (EasyAds.instance.showInterstitialAd()) {
  // Canceling the last callback subscribed
  _streamSubscription?.cancel();
  // Listening to the callback from showInterstitialAd()
  _streamSubscription =
  EasyAds.instance.onEvent.listen((event) {
    if (event.adUnitType == AdUnitType.interstitial &&
        event.type == AdEventType.adDismissed) {
      _streamSubscription?.cancel();
      goToNextScreen(countryList[index]);
    }
  });
}

Authors

Noor Ali Butt

GitHub Follow LinkedIn Link

所属分类

依赖

依赖清单 3 项

源码仓库

使用此插件的项目

暂无相关数据。