Skip to content
Docs/SDKs

Flutter (Dart)

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

Experimental — verify runtime eligibility

Test click navigation and HTML rendering for each target platform. Publication does not verify every desktop or mobile runtime. Public package: Verified. Source version: 1.0.0. See availability and capability evidence.
Packagetheaimart_adx
LanguageDart
DistributionPublic package 1.0.0 verified; runtime eligibility pending
RequirementsAny recent Flutter SDK.

Install

Pinned public package

bash
flutter pub add 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'));
// Render first; report only after measuring actual viewability.
// if (ad.filled && ad.isTrackable) await adx.reportViewable(ad.impId!);
adx.close();
Test click navigation and HTML rendering for each target platform. Publication does not verify every desktop or mobile runtime.

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