loadFromFile method
Load configuration from a JSON file at path into the given scope.
Returns false if the file does not exist or cannot be parsed.
Implementation
Future<bool> loadFromFile(
String path, {
ConfigScope scope = ConfigScope.global,
}) async {
final file = File(path);
if (!await file.exists()) return false;
try {
final content = await file.readAsString();
final map = json.decode(content) as Map<String, dynamic>;
for (final entry in map.entries) {
_store[scope]![entry.key] = entry.value;
_sources[scope]![entry.key] = ConfigSource.file;
}
return true;
} catch (_) {
return false;
}
}