cobalt_inspector 1.5.0 copy "cobalt_inspector: ^1.5.0" to clipboard
cobalt_inspector: ^1.5.0 copied to clipboard

In-app inspector for Cobalt — the live scope tree, what was built and with what lifetime, and the event log, on a screen inside your app.

example/example.md

cobalt_inspector example #

Install the log where the graph is built, then open the screen from a debug menu.

import 'package:cobalt_flutter/cobalt_flutter.dart';
import 'package:cobalt_inspector/cobalt_inspector.dart';
import 'package:flutter/material.dart';

final log = CobaltInspectorLog();

Future<void> main() async {
  final scope = await CobaltApplication.start(
    root: const AppScope(),
    rootName: 'app',
    observers: [log],
  );

  runApp(
    MaterialApp(
      home: CobaltScopeProvider(scope: scope, child: const HomeScreen()),
    ),
  );
}

class DebugMenuButton extends StatelessWidget {
  const DebugMenuButton({super.key});

  @override
  Widget build(BuildContext context) => IconButton(
    icon: const Icon(Icons.account_tree_outlined),
    // Read the scope here, at the button: a pushed route is built by the
    // navigator, which sits above the provider.
    onPressed: () => Navigator.of(context).push(
      MaterialPageRoute<void>(
        builder: (_) =>
            CobaltInspectorScreen(log: log, scope: context.cobaltScope),
      ),
    ),
  );
}

The log cannot be attached later: a scope fixes its observers when it is constructed and passes them to every child it pushes.

The screens take their colours from the host's Theme and their language from the host's locale, so nothing above is required for either. To choose them, pass theme: or put an CobaltInspectorTheme above the debug menu, and add CobaltInspectorL10n.delegate to the app's localizationsDelegates.

0
likes
160
points
1.1k
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

In-app inspector for Cobalt — the live scope tree, what was built and with what lifetime, and the event log, on a screen inside your app.

Repository (GitHub)
View/report issues
Contributing

Topics

#dependency-injection #di #devtools #debugging

License

MIT (license)

Dependencies

cobalt, cobalt_flutter, flutter, flutter_localizations, intl

More

Packages that depend on cobalt_inspector