streamFile static method
Static method to stream text content from any supported file.
This method automatically selects the appropriate stringer based on the file extension. If no suitable stringer is found, it falls back to the TextFileStringer.
@param file The file to extract text from @return A stream of strings containing the file's text content @throws Exception if the file doesn't exist
Implementation
static Stream<String> streamFile(File file) async* {
if (!file.existsSync()) {
error("File does not exist: ${file.path}");
throw Exception("File does not exist: ${file.path}");
}
for (FileStringer s in fileStringers) {
if (s.isSupported(file)) {
yield* s.stream(file);
return;
}
}
warn(
"No stringer found for file: ${file.path}, trying with text stringer...",
);
yield* const TextFileStringer().stream(file);
}