toGZipFile static method
This function converts a map of ndJson Strings (really any strings, but it was made for ndJson strings), and converts them into the bytes for a .gz file.
Each function takes a Map<String, String> value as an argument. It assumes that each value should be stored in a different file, and the key is the filename (with the appropriate extensions).
Thus if you pass a map of {patients: patientNdJson, practitioner: practitionerNdJson} The archive will include patients.ndjson and practitioner.ndjson
Lastly, these functions do not return the actual file, so you will have to do a File('fhirData.gz').writeAsBytes(value) in order to store the result somewhere.
Implementation
static List<int>? toGZipFile(Map<String, String> ndJsonStrings) {
final Archive archive = Archive();
ndJsonStrings.forEach((String key, String value) {
final ArchiveFile file =
ArchiveFile('$key.ndjson', value.length, utf8.encode(value));
archive.addFile(file);
});
return GZipEncoder().encode(archive);
}