Blog
The team5 min read

How to automate demo videos of a Flutter app

Driving a Flutter app on the iOS simulator for a narrated demo: an injected Dart driver or Maestro, finding widgets, timing scenes, recording cleanly.

Filming a web app is the easy case. You have Playwright, a DOM, selectors, and a browser that records itself. Filming a Flutter app is harder. The app runs on a simulator, draws its own pixels, and doesn't expose a DOM to anything outside it.

We needed it anyway. The first app we ever filmed was Proofit, a Flutter app for weekly workouts with friends, proven by photo. This post explains how we drive a Flutter app for a demo video today, what we tried, and what we chose.

What a demo needs from a driver

A test driver and a demo driver don't need the same things.

A test cares about the result: did the right text appear? A demo cares about the path. It has to look natural on screen, wait for animations, pause on the result long enough to read it, and tell the recording exactly when each scene starts and ends, to the millisecond, so the voice and the picture line up.

So we needed four things:

  • find widgets reliably, without coordinates;
  • run a sequence of steps per scene, at a human pace;
  • hold the screen as long as the scene's voice lasts;
  • log precise timestamps for the edit.

Option one: Maestro

Maestro is the obvious candidate. It drives iOS and Android apps from the outside, with simple YAML flows, and it doesn't require touching the app's code. It also works for native apps, not just Flutter.

For our use, it had drawbacks:

  • it only sees the accessibility tree, not Flutter Keys, so widgets without a semantic label are hard to target;
  • on iOS it goes through XCTest, which adds about a second per command, and that shows on screen;
  • it needs Java on the machine;
  • it doesn't give precise scene timestamps, which our edit depends on.

We kept Maestro on the list for native iOS and Android apps, later. For Flutter, we chose the other road.

Option two: a driver inside the app

Flutter ships its own widget-testing machinery, and part of it works on a live app. LiveWidgetController, from flutter_test, can find widgets and tap them on a running app, on a real binding. That is what our hand-made prototype used, and it worked.

So the driver lives inside the app. It is one fixed Dart file, showcase_driver.dart, that interprets a plan. The plan itself is generated for each video as showcase_plan.g.dart: the scenes, their steps, and how long each one must hold.

Never on your working copy

We never touch your repository. The runner exports the head commit of the branch with git archive into a separate -run copy, and works there. It adds the two Dart files to lib/, and one line to the demo entry point, right after runApp(:

if (const bool.fromEnvironment('SHOWCASE')) runShowcaseTour();

Then the app is started with --dart-define=SHOWCASE=true. Without that flag the line does nothing. The copy is thrown away after the run.

The demo entry point

Which entry point? If the app has a lib/main_demo.dart, we use it. That's the convention we follow: an entry that runs on demo data, with no backend. Proofit has one, which is why its demo shows realistic circles and workouts without a single real user.

If your app has no demo entry, it needs one, or a test backend. We never film production.

Finding widgets without coordinates

The planner is an AI model, reading the code on the branch. It doesn't guess where a button is on screen. It looks up what the button is called in the code and picks a target, from the most robust to the most fragile:

  1. a Key or a test id;
  2. a semantics label;
  3. a button by its text;
  4. visible text;
  5. a field's hint text, or a tooltip;
  6. and as a last resort, a point on the screen.

The driver turns each target into a Flutter Finder: find.byKey, find.bySemanticsLabel, find.text, and so on. It waits for the widget to appear, with a timeout, instead of tapping blindly.

This is the main reason we chose an in-app driver. In Flutter, keys are the most precise handle you have, and only code running inside the app can see them.

Steps at a human pace

Each scene is a list of steps: tap, long press, type, scroll until something is visible, wait, expect a widget, go back. After each gesture, the driver waits a short beat, so the viewer sees what happened before the next thing happens. The beat depends on the pace of the video: tighter for a ten-second cut, longer for a calm walkthrough.

When the steps are done, the screen holds. The voice for each scene was generated before recording, so the driver knows how long to stay. The picture stays alive until the last word, plus a short tail. We explain why in Voice first, picture second.

Logs as the timeline

The driver talks to the outside world through debugPrint. Every line starts with SHOWCASE and ends with an epoch timestamp in milliseconds:

  • SHOWCASE ready: the app is set up, the recording can start;
  • SHOWCASE start <scene> and SHOWCASE end <scene>: the exact bounds of each scene;
  • SHOWCASE touch <x> <y>: where each tap landed, as a fraction of the screen;
  • SHOWCASE fail <scene> <step> <message>: a step that could not be done.

The runner reads this log. The scene bounds cut the recording. The touch positions drive the zooms on the action in the final edit. The failures feed the rehearsal.

Recording the simulator

On a Mac, the iOS simulator records itself:

xcrun simctl io <device> recordVideo --codec=h264 --force out.mp4

It works without opening Simulator.app, and it stops cleanly on an interrupt signal. We start it when the driver logs SHOWCASE ready, so the video doesn't begin on a splash screen.

One limit to know: the iOS simulator has no camera. In our hand-made prototype, the camera scene was filmed on the Android emulator, which has a virtual scene. Android support is coming to the product, and camera scenes will be one of the first things it unlocks. Until then, a camera scene is better shown another way, or left out.

Rehearse first

Before recording, the whole plan runs once without the camera. The driver logs failures, and at the end of each scene it reports the visible text. If a step fails, the scene goes back to the planner with what the app actually showed, and the plan is fixed.

On Proofit, pull request #19, a "Close" button was mistargeted. The rehearsal caught it, the target was fixed, and the 1 min 03 video came out with that single automatic fix. The long version is in Rehearse before you record.

Making your Flutter app easy to film

You don't have to change anything for this to work. But a few habits make demos more reliable, and they help your tests and accessibility too:

  • give important widgets a Key or a semantics label;
  • keep a main_demo.dart that runs on fake data;
  • make first-run tips and onboarding skippable in demo mode;
  • avoid layouts where the same text appears several times on one screen.

That last one is the classic trap. If "Save" appears twice, the driver has to guess, and so does your user.