marionette_flutter 0.6.0 copy "marionette_flutter: ^0.6.0" to clipboard
marionette_flutter: ^0.6.0 copied to clipboard

Flutter extensions for AI agent interaction via MCP — lets Claude, Copilot, and Cursor tap, scroll, type, and screenshot your app.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:logging/logging.dart';
import 'package:marionette_flutter/marionette_flutter.dart';

void main() {
  MarionetteBinding.ensureInitialized();

  Logger.root.level = Level.ALL;
  Logger.root.onRecord.listen((record) {
    // ignore: avoid_print
    print('${record.level.name}: ${record.time}: ${record.message}');
  });

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final _logger = Logger('MyHomePage');

  int _counter = 0;

  void _incrementCounter() {
    _logger.info('Incrementing counter, from $_counter');
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      // The arrowUp shortcut demonstrates press_key: an autofocused
      // CallbackShortcuts increments the counter whenever the Up arrow is
      // pressed, so `marionette press-key --key arrowUp` works end-to-end.
      body: CallbackShortcuts(
        bindings: {
          const SingleActivator(LogicalKeyboardKey.arrowUp): _incrementCounter,
          // Modifier-gated: only control+arrowDown fires (plain arrowDown does
          // nothing), so press_key modifiers can be verified end-to-end.
          const SingleActivator(LogicalKeyboardKey.arrowDown, control: true):
              () => setState(() => _counter += 10),
        },
        child: Focus(
          autofocus: true,
          child: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                const Text('You have pushed the button this many times:'),
                Text(
                  '$_counter',
                  style: Theme.of(context).textTheme.headlineMedium,
                ),
                Padding(
                  padding: const EdgeInsets.symmetric(
                    horizontal: 32,
                    vertical: 24,
                  ),
                  child: TextField(
                    key: const ValueKey('demo_field'),
                    decoration: const InputDecoration(
                      labelText: 'Type something',
                      border: OutlineInputBorder(),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}
50
likes
160
points
100k
downloads

Documentation

API reference

Publisher

verified publisherleancode.co

Weekly Downloads

Flutter extensions for AI agent interaction via MCP — lets Claude, Copilot, and Cursor tap, scroll, type, and screenshot your app.

Repository (GitHub)
View/report issues

Topics

#mcp #ai #claude #agent #copilot

License

Apache-2.0 (license)

Dependencies

flutter, meta, web

More

Packages that depend on marionette_flutter