A loggy extensions package.

Features

  • Logs inspector
  • Dio integrations
  • Navigation logging
  • Bloc log observer

Getting started

You can use this package with loggy package. Add loggy and anadea_flutter_loggy dependencies to your project.

Usage

For inspector overlay simply add inspector wrapper to the app builder.

class ExampleApp extends StatelessWidget {
  const ExampleApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      builder: (context, child) => Inspector(
        child: child!,
      ),
      ...
    );
  }
}

Dio integration

For dio logging add LogInterceptor to the dio instanse.

final dio = Dio()..interceptors.add(LogInterceptor());

Add LogNavigatorObserver to the navigator.

@override
Widget build(BuildContext context) {
    return MaterialApp(
        navigatorObservers: [LogNavigatorObserver()], // This line
        builder: (context, child) => Inspector(
            child: child!,
        ),
        ...
    );
}

Bloc integration

Add LogBlocObserver for zone.

void main() {
  BlocOverrides.runZoned(
    () async {
      Loggy.initLoggy(
        logPrinter: StreamPrinter(const PrettyPrinter()),
      );

      runApp(ExampleApp());
    },
    blocObserver: LogBlocObserver(),
  );
}

Custom actions

You can add additional Inspector functionality by adding custom actions. Basically, this is just the AppBar.actions field.

...
builder: (context, child) => Inspector(
  customRecordBuilders: {
    TestLogModel: (context, record) => Text(record.object.toString())
  },
  isShow: true,
  actions: [
    IconButton(
      onPressed: () => ScaffoldMessenger.of(context).showSnackBar(
        const SnackBar(content: Text("Custom action pressed")),
      ),
      icon: const Icon(Icons.favorite),
    )
  ],
  child: child!,
),
...