runWithConsoleMarkdownSync<T> function

T runWithConsoleMarkdownSync<T>(
  1. T body(), {
  2. void onError(
    1. Object error,
    2. StackTrace stack
    )?,
})

Synchronous variant of runWithConsoleMarkdown for tools that don't need async (rarely used — prefer the async version).

Implementation

T runWithConsoleMarkdownSync<T>(
  T Function() body, {
  void Function(Object error, StackTrace stack)? onError,
}) {
  if (isConsoleMarkdownActive) {
    return body();
  }

  return runZoned(
    body,
    zoneSpecification: ZoneSpecification(
      print: (Zone self, ZoneDelegate parent, Zone zone, String line) {
        parent.print(zone, line.toConsole());
      },
    ),
    zoneValues: {kConsoleMarkdownZoneKey: true},
  );
}