ensureReady method
Implementation
Future<void> ensureReady() async {
if (_directory != null && _file != null) {
return;
}
final homeDir =
Platform.environment['HOME'] ?? Platform.environment['USERPROFILE'];
if (homeDir == null || homeDir.isEmpty) {
throw Exception('Could not determine home directory');
}
final directory = Directory(
path.join(homeDir, '.atsign', 'at_activate_web'),
);
final file = File(path.join(directory.path, 'config.json'));
if (!await directory.exists()) {
await directory.create(recursive: true);
}
if (!await file.exists()) {
await file.writeAsString(jsonEncode(const AppConfig().toJson()));
}
_directory = directory;
_file = file;
}