watchdog 0.1.3
watchdog: ^0.1.3 copied to clipboard
A Flutter developer toolkit that streams HTTP requests, responses, BLoC lifecycle events, navigation, and app logs to a browser-based DevTools page in real-time.
example/lib/main.dart
// Minimal integration example for the Watchdog package.
import 'package:flutter/material.dart';
import 'package:watchdog/watchdog.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Watchdog.initialize(
config: const WatchdogConfig(
apiBaseUrl: 'https://api.example.com',
port: 8888,
maskSensitiveHeaders: true,
),
);
await Watchdog.start();
runApp(const ExampleApp());
}
class ExampleApp extends StatelessWidget {
const ExampleApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Watchdog Example',
debugShowCheckedModeBanner: false,
home: ExamplePage(),
);
}
}
class ExamplePage extends StatelessWidget {
const ExamplePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('🐕 Watchdog Example')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
'Open http://localhost:8888 in Chrome\n'
'to see live logs and network events.',
textAlign: TextAlign.center,
),
const SizedBox(height: 24),
ElevatedButton(
onPressed: () {
Watchdog.info('Button tapped', stackTrace: StackTrace.current);
},
child: const Text('Log an INFO event'),
),
const SizedBox(height: 12),
ElevatedButton(
style: ElevatedButton.styleFrom(backgroundColor: Colors.orange),
onPressed: () {
Watchdog.warning('This is a warning');
},
child: const Text('Log a WARNING'),
),
const SizedBox(height: 12),
ElevatedButton(
style: ElevatedButton.styleFrom(backgroundColor: Colors.red),
onPressed: () {
Watchdog.error(
'Simulated error',
error: Exception('Something went wrong'),
stackTrace: StackTrace.current,
);
},
child: const Text('Log an ERROR'),
),
],
),
),
);
}
}