flutter_wright 0.9.2
flutter_wright: ^0.9.2 copied to clipboard
Playwright-style control of a running Flutter app — snapshot, tap, type, assert — for AI-driven and automated end-to-end testing. Debug-only in-app HTTP server.
import 'package:flutter/material.dart';
import 'package:flutter_wright/flutter_wright.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
// Start the in-app control server. Guarded by kDebugMode, so release builds
// are a no-op and the line is safe to ship.
//
// Drive it from your laptop once the app is running:
// adb forward tcp:9123 tcp:9123
// curl localhost:9123/snapshot
// curl -X POST localhost:9123/tap -d '{"ref":"s10"}'
await FlutterWright.start(enabled: kDebugMode);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'flutter_wright example',
home: CounterPage(),
);
}
}
class CounterPage extends StatefulWidget {
const CounterPage({super.key});
@override
State<CounterPage> createState() => _CounterPageState();
}
class _CounterPageState extends State<CounterPage> {
int _count = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('flutter_wright example')),
body: Center(
child: Text(
'Tapped $_count times',
style: Theme.of(context).textTheme.headlineSmall,
),
),
floatingActionButton: FloatingActionButton(
onPressed: () => setState(() => _count++),
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}