saveToFile method
Save configuration for scope to a JSON file at path.
Implementation
Future<void> saveToFile(
String path, {
ConfigScope scope = ConfigScope.global,
}) async {
final file = File(path);
await file.parent.create(recursive: true);
final data = _store[scope]!;
// Filter out sensitive keys from the written file.
final safe = Map<String, dynamic>.from(data);
safe.remove(ConfigKeys.apiKey);
final encoder = const JsonEncoder.withIndent(' ');
await file.writeAsString(encoder.convert(safe));
}