loadFromLocal method

Future<FeatureGateConfig> loadFromLocal()

Loads gate overrides from the local config file.

Returns the loaded config, or evaluates a fresh one if no file exists.

Implementation

Future<FeatureGateConfig> loadFromLocal() async {
  if (_configPath == null) {
    return evaluateForPlan(_plan);
  }
  final file = File(_configPath);
  if (!await file.exists()) {
    return evaluateForPlan(_plan);
  }
  final content = await file.readAsString();
  final json = jsonDecode(content) as Map<String, dynamic>;
  final config = FeatureGateConfig.fromJson(json);
  _applyConfig(config);
  return config;
}