watchdog 0.1.4 copy "watchdog: ^0.1.4" to clipboard
watchdog: ^0.1.4 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'),
            ),
          ],
        ),
      ),
    );
  }
}
4
likes
0
points
136
downloads

Publisher

unverified uploader

Weekly Downloads

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.

Repository (GitHub)
View/report issues

Topics

#devtools #debugging #logging #http-inspector #developer-tools

License

unknown (license)

Dependencies

chopper, flutter, flutter_bloc, get_it, http, shelf, shelf_router, shelf_web_socket, talker, talker_flutter, uuid, web_socket_channel

More

Packages that depend on watchdog