print_buffer 0.1.0 copy "print_buffer: ^0.1.0" to clipboard
print_buffer: ^0.1.0 copied to clipboard

Buffers the output of 'print' function and returns it as a string, optionally preprocesses each call.

example/lib/main.dart

import 'dart:io';

import 'package:print_buffer/print_buffer.dart';

Future<void> main() async {
  await runUnchangedBuffer();
  print('--');
  await runBufferedWithTimestamp();
}

Future<void> runUnchangedBuffer() async {
  print('Start buffering unchanged');

  final buffer = PrintBuffer();
  await buffer.run(() {
    print('Buffered unchanged 1');
    buffer.isBuffering = false;
    print('Buffering paused');
    buffer.isBuffering = true;
    print('Buffered unchanged 2');
  });

  print('End buffering unchanged');
  stdout.write(buffer.buffer);
}

Future<void> runBufferedWithTimestamp() async {
  print('Start buffering with timestamp');

  final buffer = PrintBuffer(
    transformers: [utcDate, utcTimeSeconds],
  );

  await buffer.run(() {
    print('Buffered with timestamp');
    buffer.isBuffering = false;
    print('Buffering paused');
    buffer.isTransforming = false;
    print('Buffering and transforming paused');
    buffer.isBuffering = true;
    print('Buffered without timestamp');
  });

  print('End buffering with timestamp');
  stdout.write(buffer.buffer);
}
1
likes
160
points
12
downloads

Publisher

verified publisherainkin.com

Weekly Downloads

Buffers the output of 'print' function and returns it as a string, optionally preprocesses each call.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT-0 (license)

Dependencies

clock

More

Packages that depend on print_buffer