搜尋套件、儲存庫與 APP 分類

套件詳情v2.0.1

admob_easy

簡化您的 Flutter 應用與 Google AdMob 的整合,輕鬆實現盈利。

AndroidiOS
近 30 天下載
159
喜歡數
26
Pub 分數
130

安裝套件

flutter pub add admob_easy

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

admob_easy 是一個 Flutter 套件,可簡化與 Google AdMob 的整合,讓開發者能快速在 Android 與 iOS 應用中加入廣告。它提供簡單易用的 API,用於顯示橫幅、插頁與獎勵廣告,無需深入瞭解原生廣告實作。該套件可順暢處理初始化與廣告載入,減少重複程式碼並簡化收益流程。非常適合尋求直接方式從應用獲利的開發者。

適用情境

  • 透過橫幅廣告 monetizing 移動應用
  • 在應用畫面之間顯示插頁廣告
  • 實施獎勵視頻廣告以激勵使用者
  • 無需原生程式碼即可快速整合廣告
  • 為中小型專案啟用應用內廣告

主要特色

  • 用於廣告投放的簡單 API
  • 支援橫幅廣告、插頁廣告和獎勵廣告
  • 自動廣告初始化
  • 跨平台相容性(Android 與 iOS)
  • 所需設定最少

適合對象

  • 初學者Flutter開發者
  • 需要快速廣告整合的應用程式
  • 開發時間有限的項目
  • 獨立開發者專注於變現
  • 尋找簡單廣告支援的小型到中型應用

使用建議

  • 需要設定 Google AdMob 帳戶
  • 廣告表現取決於網路可用性
  • 可能需要遵守AdMob政策
  • 與原生 SDK 相比,自訂功能有限
  • 不適合複雜的廣告邏輯或進階定位

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Admob Easy

This documentation guides integrating ads into a Flutter application using the provided helper classes.
AdMob Easy automatically handles the User Messaging Platform (UMP) for you, ensuring compliance with privacy regulations.


Android Manifest File (Android)

<manifest>
    ...
    <application>
       ...
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-3940256099942544~3347511713"/>
    </application>
</manifest>

iOS Info.plist File (iOS)

...
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>
...

Initialize MobileAds

To enable ad support, initialize AdmobEasy in the Splash Screen by providing the necessary ad unit IDs and test devices:

AdmobEasy.instance.initialize(
  androidRewardedAdID: 'ca-app-pub-3940256099942544/5224354917',
  androidInitAdID: 'ca-app-pub-3940256099942544/1033173712',
  androidBannerAdID: 'ca-app-pub-3940256099942544/6300978111',
  androidAppOpenAdID: 'ca-app-pub-3940256099942544/9257395921',
  testDevices: ['543E082C0B43E6BF17AF6D4F72541F51'],
);

Load Ads

Use the provided methods to load ads:

AdmobEasy.instance.createRewardedAd(context);    // Load rewarded ad
AdmobEasy.instance.createInterstitialAd(context); // Load Interstitial ad
AdmobEasy.instance.loadAppOpenAd();              // Load App Open Ad (shows automatically after load)

Show Ads

Once ads are loaded, show them using:

AdmobEasy.instance.showRewardedAd(context);
AdmobEasy.instance.showInterstitialAd(context);

Native Ads (New API)

Native ads are now handled via methods mixed directly into AdmobEasy.
You can preload, show, and dispose native ads with full control.


Load a Native Ad

AdmobEasy.instance.loadNativeAd(
  templateType: TemplateType.medium,
  minWidth: 320,
  minHeight: 90,
  maxWidth: 400,
  maxHeight: 200,
  adID: "ca-app-pub-3940256099942544/2247696110", // optional custom ID
  onAdClicked: (ad) => print("Ad Clicked"),
  onAdImpression: (ad) => print("Ad Impression Logged"),
  onAdClosed: (ad) => print("Ad Closed"),
  onAdOpened: (ad) => print("Ad Opened"),
  onAdWillDismissScreen: (ad) => print("Ad will dismiss screen"),
  onPaidEvent: (ad, value, precision, currencyCode) {
    print("Paid event: $value $currencyCode (precision: $precision)");
  },
);

Show a Native Ad

Once preloaded, show it anywhere in the widget tree:

class NativeAdScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Native Ad Example')),
      body: Center(
        child: AdmobEasy.instance.showNativeAd(
          minWidth: 320,
          minHeight: 90,
          maxWidth: 400,
          maxHeight: 200,
        ),
      ),
    );
  }
}

Dispose a Native Ad

When you no longer need the preloaded ad:

@override
void dispose() {
  AdmobEasy.instance.disposeNative();
  super.dispose();
}

Parameters

  • adID → Custom AdMob Unit ID (if null, defaults to AdmobEasy.instance.nativeAdID).
  • templateType → Choose between TemplateType.small or TemplateType.medium.
  • minWidth, minHeight, maxWidth, maxHeight → Controls the size of the ad container.
  • onAdClicked → Callback when the ad is clicked.
  • onAdImpression → Callback when an ad impression is logged.
  • onAdClosed → Callback when the ad is closed.
  • onAdOpened → Callback when the ad is opened.
  • onAdWillDismissScreen → Callback when the ad is about to dismiss the screen.
  • onPaidEvent → Callback for handling paid events from the ad.

Best Practices for Native Ads

✅ Preload early – Call loadNativeAd() on your splash screen or just before the screen where the ad will be shown.
✅ Dispose when unused – Always call disposeNative() when leaving the screen to free memory.
✅ Avoid multiple preload calls – The mixin ensures only one native ad is preloaded at a time.
✅ Handle callbacks – Use onAdClicked, onAdImpression, and onPaidEvent to track engagement and revenue.
✅ Fallback UI – If no ad is preloaded, showNativeAd() automatically shows a loading placeholder.


Internet Connectivity

Admob Easy automatically checks if the device is online before loading ads.

You can check connectivity manually:

AdmobEasy.instance.isConnected.value; // true if connected

Or use a listener:

ValueListenableBuilder(
  valueListenable: ConnectivityController.instance.isConnected,
  builder: (_, value, child) {
    return Text(value ? "Connected" : "No Internet");
  },
);

You can also initialize connectivity monitoring:

AdmobEasy.instance.initConnectivity(
  onOnline: () => print("Online"),
  onOffline: () => print("Offline"),
);

Support

If you find this package useful and want to support its development, you can buy me a coffee:

Buy Me a Coffee

Thank you for your support!


Contributions are welcome!

Feel free to submit bug reports, feature requests, or pull requests on GitHub.

所屬分類

依賴

依賴清單 4 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。