vantage 0.1.3
vantage: ^0.1.3 copied to clipboard
An in-app QA & developer-tools HUD for Flutter — device simulation, widget inspection, and an extensible plugin architecture for building QA tooling.
import 'package:flutter/material.dart';
import 'package:vantage/vantage.dart';
import 'package:vantage_a11y/vantage_a11y.dart';
import 'package:vantage_device_preview/vantage_device_preview.dart';
import 'package:vantage_flight_recorder/vantage_flight_recorder.dart';
import 'package:vantage_performance/vantage_performance.dart';
import 'package:vantage_prefs/vantage_prefs.dart';
import 'demo_plugin.dart';
import 'flight_recorder_demo.dart';
/// Hoisted above `main` so `routeObserver` is reachable from the app widget:
/// route attribution for the jank journal is a cooperative install.
final performance = VantagePerformancePlugin();
void main() {
runApp(
Vantage(
// Vantage is developer tooling, so `enabled` already defaults to
// `!kReleaseMode` — passing it explicitly here would be redundant. If you
// need a release-mode QA build, pass `enabled: true` deliberately.
//
// Registration order matters: the device-preview wrapper is registered
// first, so its viewport is the outermost app wrapper. The others
// contribute no app wrapper at all, so appending them is order-neutral —
// it only affects HUD tab order.
//
// Note what the composition means for the a11y audit: with a device
// preset selected, `VantageDeviceViewport` scales the app subtree with a
// `FittedBox`, so measured tap targets are in *screen* logical pixels,
// not the simulated device's.
plugins: [
VantageDevicePreviewPlugin.withFrames(),
VantageFlightRecorderPlugin(),
DemoPlugin(),
performance,
VantagePrefsPlugin(),
VantageA11yPlugin(),
],
builder: (context) => VantageExampleApp(performance: performance),
),
);
}
class VantageExampleApp extends StatelessWidget {
const VantageExampleApp({required this.performance, super.key});
/// Only needed for `navigatorObservers` — the HUD itself needs no wiring.
final VantagePerformancePlugin performance;
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Vantage Example',
builder: Vantage.appBuilder,
navigatorObservers: [performance.routeObserver],
// Unchanged: simulated brightness reaches MediaQuery.platformBrightness,
// never ThemeData, so dark mode is cooperative and the app wires it
// itself. Do not collapse this into a `theme:` argument.
home: Builder(
builder: (context) {
final dark =
MediaQuery.platformBrightnessOf(context) == Brightness.dark;
return Theme(
data: ThemeData(
colorSchemeSeed: Colors.indigo,
brightness: dark ? Brightness.dark : Brightness.light,
),
child: const FlightRecorderDemoPage(),
);
},
),
);
}
}
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Vantage Example')),
body: const Center(
child: Padding(
padding: EdgeInsets.all(24),
child: Text(
'Tap the floating bubble (or two-finger long-press) to open the '
'Vantage HUD, then try the Device panel and quick actions.',
textAlign: TextAlign.center,
),
),
),
);
}
}