Flutter SDK
Dart widgets via pub.dev — install, initialize, and drop in ad widgets for cross-platform ads.
I want to set up Koah's Flutter SDK. Read https://docs.koahlabs.com/SKILL.md and follow its instructions.
Koah 1.0 is stable. 1.0.0 is live on pub.dev — use the stable version range shown below. Upgrading from 0.x? Follow the migration guide. Questions: support@koahlabs.com.
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
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).
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());
}
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.
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: ...).
An unregistered slot resolves to no-fill (KoahAdNoFill) and nothing
renders — register it in the dashboard before shipping. See
Slots for setup, naming rules, and reporting.
Next Steps
- Appearance — Customize ad theming and sizing
- Slots — Break down reporting by placement
- Reference — Theme properties, events, and dependencies
- Visitor Attributes — Anonymous targeting signals
- Changelog — Release history