adster_flutter_sdk 1.0.5
adster_flutter_sdk: ^1.0.5 copied to clipboard
SDK for flutter consumers
π Adster Flutter SDK Example #
This Flutter project demonstrates the integration of the adster_flutter_sdk
for showing various ad formats including:
- Banner Ads
- Native Ads
- Interstitial Ads
- Rewarded Ads
- App open (Beta)
π± Android Setup #
π Authentication Setup for Adster Orchestration SDK #
To securely access the native Adster SDK hosted on GitHub Packages, your project must provide authentication credentials. These are required to fetch the sdk from our private Maven repository.
π¦ Step 1: Add Maven Credentials
You can provide the credentials in either of two ways:
π§ Option A: Add to gradle.properties
Add the following lines to either your projectβs android/gradle.properties
file or your global ~/.gradle/gradle.properties
:
adsterMavenUsername=YOUR_GITHUB_USERNAME
adsterMavenPassword=YOUR_PERSONAL_ACCESS_TOKEN
π‘ You can generate a GitHub Personal Access Token (classic) with
read:packages
andrepo
scopes.
π Option B: Use Environment Variables (ideal for CI/CD)
Alternatively, you can export these environment variables in your terminal or CI setup:
export ADSTER_MAVEN_USERNAME=YOUR_GITHUB_USERNAME
export ADSTER_MAVEN_PASSWORD=YOUR_PERSONAL_ACCESS_TOKEN
β οΈ Build Fails Without Credentials
If credentials are not set, the build will fail fast with a clear error message:
β Missing Adster Maven credentials.
Please set 'adsterMavenUsername' and 'adsterMavenPassword'
in gradle.properties or as environment variables.
β That's It!
Once credentials are provided, the Flutter plugin will be able to fetch and integrate the native orchestration SDK seamlessly.
If you face any issues, feel free to contact support@adster.tech.
β Manifest Changes Required for SDK #
Please add the following permissions to your Android AndroidManifest.xml
:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
If you donβt have an AdMob account and want to test SDK initialization, also add:
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-7640426597645136~3443205346" />
π iOS Setup #
Coming soon
π Banner Ads #
π Banner Ad Sizes #
Adster Ad Size | Dimensions (WxH) |
---|---|
AdsterAdSize.small |
320 x 50 |
AdsterAdSize.medium |
300 x 250 |
AdsterAdSize.custom |
Custom (w x h) |
β Example Usage #
import 'package:adster_flutter_sdk/adster_flutter_sdk.dart';
AdsterBannerAd(
adPlacementName: "adster_banner_320x50",
adSize: AdsterAdSize.small,
loadingWidget: SizedBox(
width: AdsterAdSize.small.width,
height: AdsterAdSize.small.height,
child: Card(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircularProgressIndicator(),
SizedBox(width: 10),
Text("Loading...."),
],
),
),
),
onFailure: (AdsterAdsException error) {
return Text("Banner not loaded: ${error.message}");
},
);
π¨ Native Ads #
π Native Ad Click Type #
Type of component to be tracked by GAM |
---|
AdsterNativeAdClickComponent.body |
AdsterNativeAdClickComponent.callToAction |
AdsterNativeAdClickComponent.headline |
AdsterNativeAdClickComponent.logo |
AdsterNativeAdClickComponent.ratingBar |
β Example Usage #
AdsterNativeAd(
adPlacementName: "adster_native_test",
onAdLoaded: (value, widget, clickHandler) {
return SizedBox(
height: 200,
child: Row(
children: [
SizedBox(width: 10),
Expanded(child: widget),
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(height: 10),
Row(
children: [
CachedNetworkImage(
imageUrl: value.imageUrl ?? "",
placeholder:
(context, url) =>
CircularProgressIndicator(),
errorWidget:
(context, url, error) =>
Icon(Icons.error),
),
SizedBox(width: 10),
Flexible(
child: InkWell(
onTap: () {
clickHandler.call(
AdsterNativeAdClickComponent
.headline,
);
},
child: Text(
value.headLine ?? "",
maxLines: 2,
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
),
],
),
SizedBox(height: 5),
InkWell(
onTap: () {
clickHandler.call(
AdsterNativeAdClickComponent.body,
);
},
child: Text(value.body ?? ""),
),
SizedBox(height: 5),
MaterialButton(
onPressed: () {
clickHandler.call(
AdsterNativeAdClickComponent
.callToAction,
);
},
color: Colors.grey,
child: Text(value.callToAction ?? ""),
),
],
),
),
),
],
),
);
},
onFailure: (AdsterAdsException error) {
return Text(error.message ?? "");
},
clickCallback: getNativeAdCallback(),
)
π¨ Interstitial Ads #
β Example Usage #
AdsterInterstitialAds() interstitialAds = AdsterInterstitialAds();
interstitialAds.loadInterstitialAd(
adPlacementName: "adster_interstitial_test",
callback: getInterstitialAdCallback(),
)
.then((value) {
if (value) {
interstitialAds.showInterstitialAd();
}
})
.onError((error, stackTrace) {
print(error);
});
π¨ Rewarded Ads #
β Example Usage #
AdsterRewardedAds rewardedAds = AdsterRewardedAds();
rewardedAds.loadRewardedAd(adPlacementName: "adster_rewarded_test")
.then((value) {
if (value) {
rewardedAds.showRewardedAd();
}
})
.onError((error, stackTrace) {
print(error);
});
π¨ App Opened Ads #
β Example Usage #
AdsterAppOpenedAds appOpenedAds = AdsterAppOpenedAds();
appOpenedAds
.loadAd(adPlacementName: "adster_app_opened_test")
.then((value) {
///Ad loaded and shown
print("onAppOpenAdLoaded");
})
.onError((error, stackTrace) {
///Ad failed to load
print("onFailure: $error");
});
π License #
This project is licensed under the MIT License.
See the LICENSE file for details.