saveState method

Future<String> saveState(
  1. String projectPath,
  2. ReleaseStateRecord record, {
  3. bool dryRun = false,
})

Persists record to .flutter_setup/releases/current_state.json.

Implementation

Future<String> saveState(
  String projectPath,
  ReleaseStateRecord record, {
  bool dryRun = false,
}) async {
  final filePath = getCurrentStateFilePath(projectPath);
  if (dryRun) return filePath;

  final dir = Directory(getStateDirectory(projectPath));
  if (!await dir.exists()) {
    await dir.create(recursive: true);
  }

  final file = File(filePath);
  await file.writeAsString(record.encodeJson());
  return filePath;
}