Ads

Displays Google Ads in Flet applications, based on the google_mobile_ads Flutter package.

Platform Support

  • **Supported:** iOS, Android
  • **Not Supported:** Windows, macOS, Linux, Web
  • Usage

    1. Add flet-ads to project dependencies:

        uv add flet-ads
        pip install flet-ads
        
    2. Manually add to requirements.txt or pyproject.toml.

    Example

    Demonstrates loading and displaying BannerAd and InterstitialAd with platform-specific test unit IDs.

    Packaging

    Specify your AdMob app ID to prevent crashes:

  • **pyproject.toml:**
  •     [tool.flet.android.meta_data]
        "com.google.android.gms.ads.APPLICATION_ID" = "YOUR_ADMOB_APP_ID"

    [tool.flet.ios.info] GADApplicationIdentifier = "YOUR_ADMOB_APP_ID"

  • **Build Command:**
  •     # Android
        flet build apk ... --android-meta-data com.google.android.gms.ads.APPLICATION_ID=YOUR_ADMOB_APP_ID

    # iOS flet build ipa ... --info-plist GADApplicationIdentifier=YOUR_ADMOB_APP_ID

    Test Values

  • **AdMob App ID:** "ca-app-pub-3940256099942544~3347511713"
  • **BannerAd Unit IDs:**
  • - Android: "ca-app-pub-3940256099942544/9214589741" - iOS: "ca-app-pub-3940256099942544/2435281174"
  • **InterstitialAd Unit IDs:**
  • - Android: "ca-app-pub-3940256099942544/1033173712" - iOS: "ca-app-pub-3940256099942544/4411468910"

    Replace test values with your own for production.