tryLoadSettingsSync static method

ServerpodCloudSettingsData? tryLoadSettingsSync({
  1. required String localStoragePath,
})

Synchronously loads Serverpod Cloud settings data from local storage.

Returns null if the file does not exist or cannot be read.

Implementation

static ServerpodCloudSettingsData? tryLoadSettingsSync({
  required final String localStoragePath,
}) {
  try {
    final file = File(
      p.join(localStoragePath, ResourceManagerConstants.settingsFilePath),
    );
    if (!file.existsSync()) {
      return null;
    }
    final json = file.readAsStringSync();
    final decoded = jsonDecode(json) as Map<String, dynamic>;
    return ServerpodCloudSettingsData.fromJson(decoded);
  } catch (_) {
    return null;
  }
}