printOnFailure function Null safety

void printOnFailure(
  1. String message
)

Prints message if and when the current test fails.

This is intended for test infrastructure to provide debugging information without cluttering the output for successful tests. Note that unlike print, each individual message passed to printOnFailure will be separated by a blank line.

Implementation

void printOnFailure(String message) {
  var invoker = Invoker.current;
  if (invoker == null) {
    throw StateError(
        'There is no current invoker. Please make sure that you are making the '
        'call inside a test zone.');
  }
  return invoker.printOnFailure(message);
}