testPrintOutput function

  1. @visibleForTesting
String testPrintOutput(
  1. Function callback
)

Used for testing the output of a callback that's printed in the console.

Implementation

@visibleForTesting
String testPrintOutput(final Function callback) {
  String printedText = '';
  runZoned(
    () => callback(),
    zoneSpecification: ZoneSpecification(
      print: (_, __, ___, String line) {
        printedText = line;
      },
    ),
  );
  return printedText;
}