Skip to content

Commit 7c7144b

Browse files
committed
docs(mcp): show driver-extension setup before flag use
Reorder the section so readers see the flag's origin before they hit it on the command line: gate enableFlutterDriverExtension() in main() first, launch with --dart-define second, then prompt the assistant. ENABLE_FLUTTER_DRIVER is a user-defined flag, not a Flutter built-in, so explaining it after the run command read backwards.
1 parent ed51f41 commit 7c7144b

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

src/content/ai/mcp-server.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,21 +397,35 @@ You can use the Dart and Flutter MCP server to drive a running
397397
Flutter app from your AI assistant—take screenshots, tap buttons,
398398
enter text, scroll, and hot reload.
399399

400-
Launch your app and ask your assistant to connect:
400+
On mobile and desktop, gate `enableFlutterDriverExtension()` behind a
401+
`--dart-define` flag in your app's `main()` so it stays out of
402+
production builds:
403+
404+
```dart
405+
import 'package:flutter_driver/driver_extension.dart';
406+
407+
void main() {
408+
if (const bool.fromEnvironment('ENABLE_FLUTTER_DRIVER')) {
409+
enableFlutterDriverExtension();
410+
}
411+
runApp(const MyApp());
412+
}
413+
```
414+
415+
Launch your app with the flag turned on:
401416

402417
```bash
403418
flutter run -d <device-id> --dart-define=ENABLE_FLUTTER_DRIVER=true
404419
```
405420

421+
Then ask your assistant to connect:
422+
406423
> Connect to my running Flutter app, take a screenshot, then tap "Sign In".
407424
408425
The agent uses the `dtd` tool to discover the app and `flutter_driver_command`
409426
to drive its UI—no integration test setup required.
410427

411428
:::note
412-
**Mobile (iOS, Android) and desktop**: gate
413-
`enableFlutterDriverExtension()` behind a `--dart-define` flag so it stays
414-
out of production builds.
415429
**Web**: the `flutter_driver` package doesn't compile under dart2js. Pair
416430
the Dart MCP server with a browser-driving MCP for clicks and screenshots;
417431
the Dart MCP server still handles widget tree, runtime errors, and hot

0 commit comments

Comments
 (0)