saveToLocal method

Future<void> saveToLocal()

Persists the current gate overrides to the local config file.

Implementation

Future<void> saveToLocal() async {
  if (_configPath == null) return;
  final config = FeatureGateConfig(
    gates: {for (final gate in FeatureGate.values) gate: isEnabled(gate)},
    organizationId: _organizationId,
    plan: _plan,
    evaluatedAt: DateTime.now(),
  );
  final file = File(_configPath);
  await file.parent.create(recursive: true);
  await file.writeAsString(
    const JsonEncoder.withIndent('  ').convert(config.toJson()),
  );
}