CrossPromote - Flutter

CrossPromote package compatible with Flutter.

Package Publisher MIT License

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

  1. Create an account on CrossPromote and top it up.

  2. Create your first ad, assign it to a an ad set, and create a new app.

  3. Copy your app's identifier (it's visible under your app's name in the dashboard).

  4. Add this package to your dependencies.

dependencies:
  crosspromote_flutter: latest_version
  1. Get the dependencies.
flutter pub get
  1. Use CrossPromote widget 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.image as your app id to display a placeholder image.
  • By default ads are picked randomly. To match a specific size, pass AdSize as size parameter to CrossPromote.
  • To avoid layout shift, you can pass both AdSize, and exactSize as match parameter.
  • You can also provide a custom builder to handle the layouting yourself. Any case that returns null will 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.

Maintainers