readFileStreaming function
Reads large files using streaming to reduce memory usage.
For files larger than 1MB, this method reads the content in chunks to avoid loading the entire file into memory.
Parameters:
file: The file to read
Returns: File content as string
Implementation
Future<String> readFileStreaming(File file) async {
final buffer = StringBuffer();
final stream = file.openRead();
await for (final chunk in stream.transform(utf8.decoder)) {
buffer.write(chunk);
}
return buffer.toString();
}