radarscope 0.1.1
radarscope: ^0.1.1 copied to clipboard
All-in-one umbrella for the Radar observability suite — one import and one init for Flutter memory, performance, and stability, with an overlay badge and a unified inspector.
example/README.md
radarscope example #
Minimal wiring for the radarscope umbrella package — one import, one init call,
unified overlay and inspector for both leak and perf domains.
Setup in main() #
import 'package:flutter/material.dart';
import 'package:radarscope/radarscope.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Radar.init(RadarConfig.standard());
runApp(
Radar.overlay(child: const MyApp()),
);
}
RadarConfig.standard() enables both the memory leak detector and the
performance tracer in debug/profile builds. The overlay badge reflects the
worst signal across both: green (clean), amber (jank or errors), red
(critical leaks). Tap the badge to open RadarScreen.
Wire the navigator observer #
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
navigatorObservers: [Radar.navigatorObserver],
home: const HomeScreen(),
);
}
}
Track object lifetimes #
class FeatureController {
FeatureController() {
Radar.track(this, tag: 'FeatureController');
}
void dispose() {
Radar.markDisposed(this);
}
}
Instrument operations #
// Sync span.
final result = Radar.trace('parse_config', () => parseConfig(raw));
// Async span.
final data = await Radar.traceAsync('load_feed', () => api.getFeed());
// Manual start/stop.
final handle = Radar.start('encode_image');
encoder.run(bytes, onFinished: () => handle.stop());
Open the unified inspector #
Navigator.of(context).push(
MaterialPageRoute(builder: (_) => const RadarScreen()),
);
RadarScreen shows a Leaks tab and a Performance tab.
Custom configuration #
await Radar.init(RadarConfig(
leak: LeakRadarConfig.standard(
autoScan: AutoScan(onNavigation: true, period: Duration(minutes: 2)),
showOverlay: true,
),
perf: PerfRadarConfig(
enabled: kDebugMode || kProfileMode,
showOverlay: true,
jankThresholdMicros: 8333, // 120 fps threshold
stallThresholdMicros: 100000,
),
));