FileDescriptor constructor
Creates a new FileDescriptor with name and contents.
The contents may be a String, a List<int>, or a Matcher. If it's a
string, create creates a UTF-8 file and validate parses the physical
file as UTF-8. If it's a Matcher, validate matches it against the
physical file's contents parsed as UTF-8, and create, read, and
readAsBytes are unsupported.
If contents isn't passed, create creates an empty file and validate
verifies that the file is empty.
To match a Matcher against a file's binary contents, use
FileDescriptor.binaryMatcher instead.
Implementation
factory FileDescriptor(String name, Object? contents) {
if (contents is String) return _StringFileDescriptor(name, contents);
if (contents is List) {
return _BinaryFileDescriptor(name, contents.cast<int>());
}
if (contents == null) return _BinaryFileDescriptor(name, []);
return _MatcherFileDescriptor(name, contents as Matcher);
}