Skip to main content

peek_talker 2.0.0 copy "peek_talker: ^2.0.0" to clipboard
peek_talker: ^2.0.0 copied to clipboard

Reports the calls Talker logs to Peek, so they can be read in the app.

example/peek_talker_example.dart

// Peek reads the calls Talker already logs: one adapter next to the Talker
// an app has, and the loggers it already runs feed Peek unchanged. This is
// a Dart script so it can run anywhere; the full app is under
// `packages/peek/example`.

import 'package:dio/dio.dart';
import 'package:peek/core.dart';
import 'package:peek_talker/peek_talker.dart';
import 'package:talker/talker.dart';
import 'package:talker_dio_logger/talker_dio_logger.dart';

/// Lets Peek see what Talker logged, before and after it was attached.
Future<void> main() async {
  final talker = Talker();
  final dio = Dio()..interceptors.add(TalkerDioLogger(talker: talker));

  // Logged before Peek exists: replayed from Talker's history on attach.
  await dio.get<dynamic>('https://httpbin.org/get');

  final peek = Peek();
  peek.attach(PeekTalkerAdapter(peek, talker: talker));

  // Logged after: reported live, through Talker's stream.
  await dio.get<dynamic>('https://httpbin.org/uuid');

  // The stream delivers asynchronously; give it a turn of the event loop.
  await Future<void>.delayed(Duration.zero);
  assert(peek.store.length == 2, 'both calls are in the store');

  peek.dispose();
}
1
likes
0
points
524
downloads

Publisher

unverified uploader

Weekly Downloads

Reports the calls Talker logs to Peek, so they can be read in the app.

Homepage
Repository (GitHub)
View/report issues

Topics

#debugging #http #logging #network #talker

License

unknown (license)

Dependencies

dio, peek, peek_dio, talker, talker_dio_logger

More

Packages that depend on peek_talker