SDKs

Flutter SDK

Dart widgets via pub.dev — install, initialize, and drop in ad widgets for cross-platform ads.

Prompt for coding agents

I want to set up Koah's Flutter SDK. Read https://docs.koahlabs.com/SKILL.md and follow its instructions.

Prerequisites

  • A Koah account — if you don't have one, apply for access
  • Your publisher ID from the dashboard
  • Flutter 3.29.2 or newer (the SDK requires Dart ^3.7.2)

Install

1

Add the dependency

Add koah_flutter to your pubspec.yaml, then run flutter pub get.

dependencies:
  flutter:
    sdk: flutter
  koah_flutter: ^1.0.0

In an iOS app, run pod install in your ios/ directory after upgrading (a plain flutter run also does this for you).

2

Initialize the SDK

Initialize Koah with your publisher ID at app startup.

import 'package:koah_flutter/koah_flutter.dart';

void main() {
  Koah.instance(publisherId: 'your-publisher-id');
  runApp(MyApp());
}
3

Display an ad

Drop a KoahCard into your widget tree with a KoahAdContext describing the surrounding content.

import 'package:koah_flutter/koah_flutter.dart';

KoahCard(
  adContext: KoahAdContext.conversation(
    question: 'How do I use SwiftUI?',
    answer: 'SwiftUI is a modern UI framework.',
  ),
  cacheKey: 'msg-1',
)

The KoahAdContext tells Koah what the surrounding content is about so it can match a relevant ad. The cacheKey dedupes requests so a placement reuses a single ad across rebuilds — see How Koah works.

4

Style & size your adsOptional

Theme ads to match your brand and bound each slot's size from one place — see theming and sizing on the Appearance page.

Slots

Tag an ad request with a slot to break down your dashboard reporting by where the ad renders — a feed card, an in-article unit, a chat sidebar. Register your slots in the dashboard first, then pass a registered name as slot on the imperative requestAd or prefetchAd calls:

final result = await Koah.instance().requestAd(
  adContext: KoahAdContext.feed(text: post.text, source: post.source),
  cacheKey: post.id,
  slot: 'in-article',
);

To tag a card placement, pair prefetchAd(slot: ...) with KoahCard.fromCache(cacheKey: ...).

Next Steps

Was this helpful?