popularity likes pub points building style: effective dart Wolfiz Technologies WhatsApp Awesome Flutter Buy Me A Coffee

Languages:

English Urdu

About OurAds

  • OurAds package helps to resolve coding issues you may incur, Minimize repetition of typing small things. package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

  • For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

  • OurAds has 3 basic principles. This means that these are the priority for all resources in the library: PRODUCTIVITY, PERFORMANCE AND ORGANIZATION.

    • PERFORMANCE: OurAds is focused on performance and minimum consumption of resources.

    • PRODUCTIVITY: OurAds uses an easy and pleasant syntax.

    • ORGANIZATION: OurAds can easily organizes your widgets and code.

In addition, to further increase your productivity, we have More Packages and the Ads Management Setting

OurAds Installation Guide

Please follow the complete guide to use this package.

Adding dependency

Add Get to your pubspec.yaml file:

dependencies:
  ourads: 0.0.7

Import get in files that it will be used:

import 'package:ourads/ourads.dart';

Step 1 - OurAds Initialization

Add below code before your MaterialApp, it will automatically work with Sample Test Ids, Live/Active Ids we'll add in next step.

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await OurAds().initAds(
    hasOpenAd: true,
    //If you want to use AppOpen Adds keep it true otherwise make it false
  );
  runApp(
    GetMaterialApp(
      title: "Application",
      initialRoute: AppPages.INITIAL,
      getPages: AppPages.routes,
    ),
  );
}

Step 2 - 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>
  • Note: if you want to use with live Id replace this "ca-app-pub-3940256099942544~1458002511" with your live 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 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-3940256099942544~3347511713"/>
</application>
</manifest>
  • Note : We prefer to use it with GetX and ScreenUtil Flutter Package. and its example is below.

  • Just to call Widget where ever you want to in project, but make sure to import ScreenUtil file if its not working.

Examples

AppOpenAd

  • Now you can easily call implement App Open Ad just typing below piece of code in main.dar
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await OurAds().initAds(
    //if you make it false Open ads will not work
    hasOpenAd: true,
  );
  //if you want to hide Open ads from premium users you can make logic on below command. 
  OurAds.resumeOpenAppAds();

  runApp(
          MyApp()
  );
}

- Note: Do not forget to add these lines.

  • Note: Do not forget to add these lines.
  OurAds.resumeOpenAppAds();

Interstitial Ad

  • Now you can easily call Interstitial Ad anywhere in project just by using this command
OurAds.showInterstitialAd();
  • Below is an complete example.
Scaffold(
appBar: AppBar(
title: Text('Full-Size Banner Ad'),
centerTitle: true,
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Button Below will take you '
'to the new screen '
'and also shows you \n'
'Interstitial Ad \n \n ',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600),
textAlign: TextAlign.center,
),
ElevatedButton(
onPressed: () {
OurAds.showInterstitialAd();
Get.toNamed(Routes.SHOW_INTERSTITIAL_AD);
},
child: Text('Show Interstitial Ad'),
)
],
),
);

Now You can easily call app anywhere in project

Now You don't need to call Ad type with its name.

Scaffold(
appBar: AppBar(
title: Text('Banner Ads'),
centerTitle: true,
),
body: Column(
children: [
//Now you call any add just by calling their name
StandardBanner(),
//Size in dp (320Wx50H)
LargeBanner(),
//Size in dp (320Wx100H)
MediumRectangle(),
//Size in dp (320Wx250H)
],
),
);

Full-Sized Banner

Now You don't need to type Text and its properties again and again just type. "MyText"

Scaffold(
appBar: AppBar(
title: Text('Full-Size Banner Ad'),
centerTitle: true,
),
body: Column(
children: [
//Now you call any add just by calling their name
FullSizeBanner(),
//Size in dp (468Wx60H)
],
),
);

Leaderboard

Now You don't need to type Text and its properties again and again just type. "MyText"

Scaffold(
appBar: AppBar(
title: Text('Leaderboard Ad'),
centerTitle: true,
),
body: Column(
children: [
//Now you call any add just by calling their name
Leaderboard(),
//Size in dp (468Wx60H)
],
),
);

Banner Add Sizes

1- Widget types:

Ads TypeWidget NameSize in dp (WxH)
Standard BannerStandardBanner()320x50
Large BannerLargeBanner()320x100
Medium RectangleMediumBanner()320x250
Full-Size BannerFullSizeBanner()468x60
LeaderboardLeaderboardBanner()728x90

Implementing Live Ids

  • See below piece of code and follow same way to implement Live Ids
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await OurAds(
iOSAdId: IOSAdId(
appOpenId: "Place here your iOS AppOpen Ad Id",
bannerId: "Place here your iOS  Banner Ad Id",
interstitialId: "Place here your iOS Interstitial Ad Id",
nativeId: "Place here your iOS Native Ad Id"),
androidAdId: AndroidAdId(
appOpenId: "Place here your Android AppOpen Ad Id",
bannerId: "Place here your Android Banner Ad Id",
interstitialId: "Place here your Android Interstitial Ad Id",
nativeId: "Place here your Android Native Ad Id"),
).initAds(
hasOpenAd: true,
//if you make it false Open ads will not work
);
//if you want to hide Open ads from premium users you can make logic on below command.
OurAds.resumeOpenAppAds();
runApp(MyApp());
}

Discussion

Community channels

Wolfiz Technologies has a highly active and helpful community. If you have questions, or would like any assistance regarding the use of this framework, please join our community channels, your question will be answered more quickly, and it will be the most suitable place. This repository is exclusive for opening issues, and requesting resources, but feel free to be part of GetX Community.

| WhatsApp | GitHub | | Get on WhatsApp | GitHub |

Libraries

ad_id_interface
our_banner
ourads
test_ad_id