Skip to content

SDK reference

Flutter

Every API of the playstep and playstep_embeds packages, with examples.

All PlayStep methods are static, safe to call before the config has loaded, and never throw into your app.

PlayStep.init

Starts the SDK. It returns quickly; the config loads in the background and the last good config is used offline. If the API no longer knows the key (it was rotated more than a day ago, or the app deleted), the cached config is forgotten and no guide shows; the SDK says so in the debug log and calls onEvent with { type: 'sdk_error', message: 'config_not_found' } (0.10+). Call WidgetsFlutterBinding.ensureInitialized() first when init runs before runApp.

Events go out in batches every few seconds and whenever the app loses focus, is hidden or paused. Each carries an id. A batch that cannot be sent (offline, a server error, a rate limit) is retried with backoff and kept on the device until it goes, on the next launch if need be; a retried event still counts once. If onEvent throws, the event is sent anyway.

Dart
WidgetsFlutterBinding.ensureInitialized();
await PlayStep.init(
  appKey: 'ps_pub_prod_your_key',
  locale: 'pt-BR',
  onEvent: (event) => analytics.log('playstep_${event['type']}', event),
);
ParameterDefaultWhat it does
appKeyrequiredYour publishable key.
apiBasehttps://cdn.playstep.appSelf-hosting and tests.
localeThe device localeThe language guides show in, when a guide has it (else its default). See setLocale.
onEventnoneCalled for every guide event.
confignoneUse this config instead of fetching one (preview mode).
previewfalseNothing is sent. On Flutter web, a ?playstep_preview= link from Open in my app turns it on and loads that draft (0.10+).
captureTokennoneStarts capture mode for Generate with AI. Also read from --dart-define=PLAYSTEP_CAPTURE=…, and from the capture link on Flutter web.
captureScreenshotsfalseAdds a small screenshot of each captured screen.
colorModePlayStepColorMode.autoLight or dark guides; auto follows your app's theme, then the device.
navigatenoneYour app's navigation, so a replay begins where the guide starts. See below. SDK 0.8+.
startRoutenoneFills in a guide's start route yourself, for routes that lack a * part. See below. SDK 0.9+.

guide_shown events say what started the guide in source (SDK 0.8+): trigger (a trigger), launcher (the guide list or the finish screen) or api (PlayStep.start). A guide that comes back part-way in the same run sends no second guide_shown; one resumed on a later launch sends one with the source of the start it continues (SDK 0.9+; before that, trigger).

Take users to where a guide starts

A guide can name the route it begins on (Starts on page in its settings, like /app/*/projects). Pass your app's navigation as navigate, and when someone starts that guide from another screen, PlayStep takes them there first and shows step 1 once the screen is reported (by navigatorObserver or page). That happens when they pick it in the guide list, press Replay or Next guide on the finish screen, or you call PlayStep.start. A * is filled in from the same part of the current route.

Dart
final navigatorKey = GlobalKey<NavigatorState>();
await PlayStep.init(
  appKey: 'ps_pub_prod_your_key',
  navigate: (route) => navigatorKey.currentState?.pushNamed(route),
);
MaterialApp(navigatorKey: navigatorKey, navigatorObservers: [PlayStep.navigatorObserver], /* … */);

// go_router: navigate: (route) => router.go(route), with GoRouter(observers: [PlayStep.navigatorObserver], …)

The guide begins on step 1 on that screen, so a page step the screen they came from happens to satisfy is not skipped. Triggers never navigate. Without navigate, or when a * cannot be filled in, the guide starts where the user is, as before; if navigate throws, it starts there too and an sdk_error is sent. While a guide waits for its screen, Android back is your app's.

If some of your routes lack the part a * stands for (/app/home next to /app/acme/…), filling it in from the current route would build one that does not exist (/app/home/projects). Pass startRoute and fill it in from your app's own state: it gets the start route as set in the dashboard and the guide's id, and returns the route to go to, or null to start the guide where the user is (also what happens if it throws, with an sdk_error).

Dart
startRoute: (startRoute, guideId) {
  final slug = currentWorkspace?.slug;
  return slug == null ? null : startRoute.replaceFirst('*', slug);
},

Capture mode

With a capture token, the SDK shows a small panel instead of guides. After Start capturing, each screen you open (reported by PlayStep.navigatorObserver or PlayStep.page) is read from the widget tree and sent to PlayStep: titles, the labels of buttons and fields, how to find each widget again, and your app's theme (colours, fonts and corner shapes, for Appearance › Detect from my app). What anyone typed is never read. Use it in a debug or profile build, never in a release you ship:

Terminal
flutter run --dart-define=PLAYSTEP_CAPTURE=cap_your_token

Steps created this way find their widgets without a GuideAnchor, by ValueKey, text, semantics label or tooltip. A GuideAnchor with the step's anchor id always wins.

Studio recording

Studio records your guides' clips by running your app in debug mode on an Android phone or emulator, or the iOS Simulator. Debug and profile builds answer the recorder through Flutter's own developer service (flutter run), with no network access and no port; release builds never do. While Studio records, the SDK hides its guides and launcher, sends no events, removes the debug banner and draws a small coloured mark at the left edge at the start and the end. On the iOS Simulator without idb, the SDK also taps and types for the recorder, inside the app. Nothing in your code changes: PlayStep.init, PlayStep.builder and your GuideAnchors are all it needs.

PlayStep.builder

Draws guides above every route and dialog. Use it as your app's builder:

Dart
MaterialApp(builder: PlayStep.builder, home: const HomeScreen());

PlayStep.navigatorObserver

Reports route names as screen views for page_view triggers:

Dart
MaterialApp(navigatorObservers: [PlayStep.navigatorObserver], home: const HomeScreen());

GuideAnchor

Marks a widget as an anchor. Taps on it complete tap_anchor steps.

Dart
GuideAnchor(
  id: 'new-invoice-btn',
  child: FilledButton(onPressed: createInvoice, child: const Text('New invoice')),
)

PlayStep.identify

Dart
PlayStep.identify(user.id, {'plan': 'pro'});

The id is hashed on the device, together with your publishable key, before it is sent. Traits merge with the ones you passed before; pass one as null to remove it (a null trait matches no eq, in or exists rule), and reset clears them all.

Dart
PlayStep.identify(user.id, {'role': null}); // no longer an admin; plan stays

A signed-in user's guide progress follows them across devices (0.10+; see triggers). It comes with the config when the app launches, so when you know the user at launch, call identify before PlayStep.init to have it from the first screen.

PlayStep.track

Dart
PlayStep.track('invoice_page_opened');
PlayStep.track('invoice_sent', {'amount': 49}); // properties (0.10+) go to add-ons; guides use the name

PlayStep.start

Starts a guide now, even if the user has finished it before. With navigate, a guide with a start route begins there.

Dart
IconButton(icon: const Icon(Icons.help_outline), onPressed: () => PlayStep.start('create-first-invoice'));

PlayStep.complete

Dart
await saveClient();
PlayStep.complete('fill-client');

PlayStep.page

Reports a screen view yourself, for screens without named routes. Page triggers and page steps match these names:

Dart
PlayStep.page('/invoices/new');

PlayStep.openLauncher

Opens the list of guides people can replay, whether or not the floating button is on, so you can open it from your own help menu. It does nothing when there are no guides to list. A guide that is showing waits while the list is open and carries on when it closes. The list has a close button, Replay on each guide the user has started and Start over; Android back closes it.

Dart
ListTile(title: const Text('Replay product tours'), onTap: PlayStep.openLauncher);

PlayStep.resetProgress

Clears guide progress on this device so guides can start again: every guide, or only the one you name. The user, their traits and the device id stay. A guide it clears closes, first-visit and screen triggers are checked again for the current screen straight away, and it reports a progress_reset event. Before init has finished, it waits for it. It applies to this device; to let a guide start again on all of a signed-in user's devices, use the server API.

Dart
PlayStep.resetProgress(); // every guide
PlayStep.resetProgress('create-first-invoice'); // one guide
PlayStep.start('create-first-invoice'); // and play it now

PlayStep.setColorMode

Guides wear your app's appearance and by default follow your app's theme: MaterialApp(themeMode: …) or a CupertinoApp's brightness, then the device setting, switching while a guide is showing. Call this only when your app keeps its light or dark mode outside its theme. A guide or appearance set to always light or always dark wins over it.

Dart
PlayStep.setColorMode(PlayStepColorMode.dark);
PlayStep.setColorMode(PlayStepColorMode.auto); // follow the app again

A font in your appearance must be a family your app already bundles (the first name in the list is used).

PlayStep.setLocale

Shows guides in another language from now on, for an app that switches language without a restart. The SDK fetches that language's guides from PlayStep (one small request), and a guide that is showing switches to it at the same step. 0.7+.

Dart
PlayStep.setLocale('fr');

Each guide shows in the user's language when it has it (fr-CA uses fr), else in its default language; text not translated yet falls back too. The card's own words follow the same language, from your app's languages, and Arabic, Hebrew, Persian and Urdu read right to left.

PlayStep.reset

Forgets the user, their traits and their progress on this device. Call it on sign-out. Their progress kept on the server stays, for when they sign in again. To let a signed-in user replay guides, use resetProgress.

Dart
await PlayStep.reset();

It does not end a pause.

PlayStep.pause and PlayStep.resume

Stops guides for now, for a user who should not see them at the moment: a guest in this workspace, say, who was a member in the last one.

Dart
if (workspace.role == 'guest') {
  PlayStep.pause();
} else {
  PlayStep.resume();
}

if (PlayStep.isPaused) hideToursMenuItem();

While paused nothing starts (events, screen views, first-visit triggers and start do nothing), a guide that is showing leaves the screen with nothing stored and no event sent, and the guide list closes and cannot open. Stored progress is untouched. PlayStep.resume() brings the guide that was showing back on the same step; with none showing, it checks first-visit and screen triggers again against the user's traits as they are now. PlayStep.isPaused tells you whether guides are paused. A pause lasts until resume() or the app restarts.

Use reset on sign-out, pause when the signed-in user should not see guides right now, and resetProgress to let guides play again.

PlayStep.use

Attaches an add-on (0.10+): a PlayStepPlugin that hears the config once it has loaded, then identify (with every trait so far), track (with its properties), screens, reset and the app moving to and from the background. Override only what you need. When the app's config turns analytics on, the first add-on also hears up to 50 calls made before the config loaded; otherwise those are dropped. An add-on that throws is reported and never breaks your app, and an app turned off with the kill switch tells add-ons nothing. Attaching the same add-on again does nothing.

Dart
class LogEvents extends PlayStepPlugin {
  @override
  void onTrack(String event, Map<String, Object?>? props) => debugPrint('PlayStep event $event $props');
}

PlayStep.use(LogEvents());

Back button and keyboard

Android back works on PlayStep's cards like on a dialog:

  • On a step card, back hides the guide for now. It is not a dismissal: no guide_dismissed is sent, nothing starts the guide again on its own until the app is launched again (or progress is reset), and the next launch picks it up at the same step. The launcher can still start it.
  • On the completion card or the guide list, back closes it.

While one of your app's own dialogs, bottom sheets, menus or dropdowns is open (a popup route on the navigator that has PlayStep.navigatorObserver), back is your app's and PlayStep leaves it alone. Focus moves to the card for screen readers, and steps are announced.

playstep_embeds

Plays YouTube and Vimeo clips inline, in a web view, when the user taps them.

Dart
await PlayStep.init(appKey: 'ps_pub_prod_your_key');
PlayStepEmbeds.register();

PlayStepEmbeds.embedUri returns the privacy-friendly embed URL for a YouTube or Vimeo link:

Dart
final uri = PlayStepEmbeds.embedUri('https://youtu.be/aqz-KE-bpKQ');

Search the docs and guides.

Request a demo

We set up every new PlayStep workspace with its team. Leave your name and email and we'll book a demo and get you started.

We use your email only to arrange the demo. See the privacy policy.