write method

bool write({
  1. Map<String, String>? environment,
})

Saves these settings; false when there is no settings folder or it can't be written (the answer then holds for this run only).

Implementation

bool write({Map<String, String>? environment}) {
  final at = path(environment: environment);
  if (at == null) return false;
  final json = {
    ...extra,
    if (alwaysDownload) 'download': 'always',
    if (declined.isNotEmpty) 'declined': declined,
  };
  try {
    writeTextAtomic(
      File(at),
      '${const JsonEncoder.withIndent('  ').convert(json)}\n',
    );
    return true;
  } on FileSystemException {
    return false;
  }
}