easy_ads_flutter 0.0.2 copy "easy_ads_flutter: ^0.0.2" to clipboard
easy_ads_flutter: ^0.0.2 copied to clipboard

outdated

Easy Ads is a wrapper around famous ad packages which let you integrate ads easily

To easily add ads into your app.

Features #

  • Google Mobile Ads (banner, interstitial, rewarded video ad)

Prerequisites #

  • Flutter 1.22.0 or higher
  • Android
    • Android Studio 3.2 or higher
    • Target Android API level 19 or higher
    • Set compileSdkVersion to 28 or higher
    • Android Gradle Plugin 4.1 or higher (this is the version supported by Flutter out of the box)
  • Ios
  • Recommended: Create an AdMob account and register an Android and/or iOS app (To show live ads on a published app, it is required to register that app).

Platform Specific Setup #

iOS #

Update your Info.plist

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

  • A GADApplicationIdentifier key with a string value of your AdMob app ID (identified in the AdMob UI).
  • A SKAdNetworkItems key with Google's SKAdNetworkIdentifier value of cstr6suwn9.skadnetwork.
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>
<key>SKAdNetworkItems</key>
  <array>
    <dict>
      <key>SKAdNetworkIdentifier</key>
      <string>cstr6suwn9.skadnetwork</string>
    </dict>
  </array>

See https://developers.google.com/admob/ios/quick-start#update\_your\_infoplist for more information about configuring Info.plist and setting up your App ID.

Android #

Update AndroidManifest.xml

The AdMob App ID must be included in the AndroidManifest.xml. Failure to do so will result in a crash on launch of an app.

Add the AdMob App ID (identified in the AdMob UI) to the app's android/app/src/main/AndroidManifest.xml file by adding a <meta-data> tag with name com.google.android.gms.ads.APPLICATION_ID, as shown below. You can find your App ID in the AdMob UI. For android:value insert your own AdMob App ID in quotes, as shown below.

<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>

The same value when you initialize the plugin in your Dart code.

See https://goo.gl/fQ2neu for more information about configuring AndroidManifest.xml and setting up the App ID.

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';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await EasyAds.instance.initialize();

  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  MyAppState createState() => MyAppState();
}

class MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    // Load ads.
  }
}

Initialize the admob #

import 'package:easy_ads_flutter/easy_ads_flutter.dart';

EasyAds.instance.initAdmob(
        interstitialAdUnitId: InterstitialAd.testAdUnitId,
        rewardedAdUnitId: RewardedAd.testAdUnitId);

load ad #

import 'package:easy_ads_flutter/easy_ads_flutter.dart';

EasyAds.instance.loadRewardedAd();

OR

EasyAds.instance.loadInterstitialAd();

showing ad #

import 'package:easy_ads_flutter/easy_ads_flutter.dart';

EasyAds.instance.showInterstitialAd();

OR

EasyAds.instance.showRewardedAd();

dispose ad #

import 'package:easy_ads_flutter/easy_ads_flutter.dart';

EasyAds.instance.disposeInterstitialAd();

OR

EasyAds.instance.disposeRewardedAd();
97
likes
0
pub points
86%
popularity

Publisher

verified publishernooralibutt.com

Easy Ads is a wrapper around famous ad packages which let you integrate ads easily

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

collection, flutter, google_mobile_ads

More

Packages that depend on easy_ads_flutter