toFile static method
Future<void>
toFile(
- ReportTemplate template,
- String filePath, {
- Map<
String, dynamic> ? additionalMetadata,
Saves a template to a file
Implementation
static Future<void> toFile(
ReportTemplate template,
String filePath, {
Map<String, dynamic>? additionalMetadata,
}) async {
try {
final file = File(filePath);
final directory = file.parent;
if (!await directory.exists()) {
await directory.create(recursive: true);
}
final rptContent = _createRptContent(template, additionalMetadata);
await file.writeAsString(jsonEncode(rptContent), encoding: utf8);
} catch (e) {
throw Exception('Error saving the template to file: $e');
}
}