matchesGoldenText function

Future<Matcher> matchesGoldenText(
  1. {@required String file,
  2. Encoding encoding = utf8}

Returns a future that completes with a Matcher checking for file contents.

If file does not exist, or the contents do not match the actual String (or Object.toString value), then the matcher will fail. To ignore failures and automatically update the golden files, see updateGoldensOnFailure.

NOTE: This method returns a Future<Matcher> that must be awaited!


Future<Matcher> matchesGoldenText({
  @required String file,
  Encoding encoding = utf8,
}) async {
  ArgumentError.checkNotNull(file, 'file');
  final handle = File(file);
  if (_updateGoldens) {
    return _StringUpdateMatcher(
      await handle.exists()
          ? await handle.readAsString(encoding: encoding)
          : '',
  } else if (!await handle.exists()) {
    return _FileNotFoundMatcher(file);
  } else {
    return _StringOutputMatcher(
      await handle.readAsString(encoding: encoding),