CrossPromote - Flutter
CrossPromote package compatible with Flutter.
crosspromote_flutter is a package that allows you to display custom ads, referrals, and sponsored content inside your app, and to manage it through a unified dashboard.
Other implementations include:
Getting started
-
Create an account on CrossPromote and top it up.
-
Create your first ad, assign it to a an ad set, and create a new app.
-
Copy your app's identifier (it's visible under your app's name in the dashboard).
-
Add this package to your dependencies.
dependencies:
crosspromote_flutter: latest_version
- Get the dependencies.
flutter pub get
- Use
CrossPromotewidget in your app.
CrossPromote(
appId: 'replace-with-your-app-id',
)
Advanced usage
You can use CrossPromoteClient directly if you want to create a custom component, or if you want to use metadata ads.
// Create a new client.
final client = new CrossPromoteClient(
// Replace with your app's identifier from CrossPromote.
appId: 'example.image',
);
// Fetch an ad.
final ad = await client.retrieve(
size: AdSize.w300h250,
match: AdMatch.preferredSize,
);
// One of the following: `image`, `metadata`, `empty`.
print(ad.type);
// An URL that redirects to a page specified in the console.
// This URL is a special variant that also tracks the number of clicks.
print(ad.targetUrl);
// Custom JSON payload specified in the console.
print(ad.payload);
// Properties available only for ads with type `image`.
if (ad is ImageAd) {
print(ad.imageUrl);
print(ad.size);
}
Additional information
- You can use predefined identifiers to test your app during development, and avoid incurring cost during testing. Use
example.imageas your app id to display a placeholder image. - By default ads are picked randomly. To match a specific size, pass
AdSizeassizeparameter toCrossPromote. - To avoid layout shift, you can pass both
AdSize, andexactSizeasmatchparameter. - You can also provide a custom
builderto handle the layouting yourself. Any case that returnsnullwill fallback to using the default implementation. - This package requires at least Flutter 3.32.0 to work.
- If there are any issues feel free to go to GitHub Issues and report a bug.