Docs/SDKs

Flutter (Dart)

One SDK for Android, iOS, web and desktop Flutter targets.

Packagetheaimart_adx
LanguageDart
Distributionpub.dev
RequirementsAny recent Flutter SDK.

Install

pubspec.yaml

yaml
dependencies:
  theaimart_adx: ^1.0.0

Usage

Drop-in banner widget

dart
import 'package:theaimart_adx/theaimart_adx.dart';

BannerAd(
  apiKey: 'pk_your_publisher_key',
  slotId: '8b1f2c3d-....-uuid',
  onAdLoaded: (ad) => debugPrint('filled ${ad.source}'),
  onAdFailed: (reason) => debugPrint('no fill: $reason'),
)

Client directly

dart
final adx = AdxClient(apiKey: 'pk_...', userAgent: platformUserAgent());
final ad = await adx.requestAd(const AdRequest(slotId: '8b1f-uuid'));
if (ad.filled && ad.isTrackable) await adx.reportViewable(ad.impId!);
adx.close();

Production hardening

  • Fraud-safe User-Agent theaimart-adx-flutter/<ver> (Android|iPhone…) via platformUserAgent() — off the backend bot blocklist, with a device token.
  • SQL-filter-safe encoding of free-text params so real URLs never trip the WAF.
  • 4-way union parsing and fail-closed rendering (errors -> no-fill, never a thrown exception).

These behaviors come directly from the wire contract — see User-Agent rules and WAF-safe encoding for why they matter. Not getting fills? See Troubleshooting.

API

MemberNotes
BannerAd({ apiKey, slotId, onAdLoaded?, onAdFailed? })Image ads render with Image.network + tap-to-open (url_launcher); pass an htmlBuilder for html/openrtb creatives (e.g. wrapping webview_flutter).
AdxClient(apiKey: …, userAgent: …)Framework-agnostic client.
adx.requestAd(const AdRequest(…))Request an ad decision.
adx.reportViewable(ad.impId!)Fire the viewability beacon.
adx.close()Release the underlying HTTP client.

The normalized Ad model

Same normalized Ad shape as the other SDKs (filled, kind, source, impId, creative, auction, isTrackable).

Build & test

bash
cd packages/flutter
flutter pub get
flutter test          # encoding + models + client (MockClient) unit tests