anadea_flutter_loggy 1.7.0 copy "anadea_flutter_loggy: ^1.7.0" to clipboard
anadea_flutter_loggy: ^1.7.0 copied to clipboard

Anadea flutter loggy package. An package extension for the loggy package with various integrations such as dio, routing and flutter_bloc.

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!,
),
...
4
likes
120
points
319
downloads

Documentation

API reference

Publisher

verified publisheranadeainc.com

Weekly Downloads

Anadea flutter loggy package. An package extension for the loggy package with various integrations such as dio, routing and flutter_bloc.

Repository

License

BSD-3-Clause (license)

Dependencies

dio, flutter, flutter_bloc, flutter_loggy, loggy, package_info_plus

More

Packages that depend on anadea_flutter_loggy