toFile method
Saves the DataCube to a JSON file.
The file contains metadata and the full 3D data structure.
Example:
var cube = DataCube.generate(3, 4, 5, (d, r, c) => d * 100 + r * 10 + c);
await cube.toFile('cube.json');
Implementation
Future<void> toFile(String path) async {
final fileIO = FileIO();
final json = {
'type': 'DataCube',
'version': '1.0',
'shape': [depth, rows, columns],
'data': data.toNestedList(),
'attributes': attrs.toJson(),
};
await fileIO.saveToFile(path, jsonEncode(json));
}