runWithPrintCapture<T> static method

T runWithPrintCapture<T>(
  1. T body()
)

Optional helper to capture print() while running your app.

Implementation

static T runWithPrintCapture<T>(T Function() body) {
  return runZoned<T>(
    body,
    zoneSpecification: ZoneSpecification(
      print: (self, parent, zone, line) {
        if (_shouldLog(line)) {
          DebugBus.instance.addLog(
            LogEvent(DateTime.now(), LogLevel.debug, line),
          );
        }
        parent.print(zone, line);
      },
    ),
  );
}