save method

Future<void> save([
  1. File? file
])

allows to save properties to a file. If a file is provided at the time of initialization that is if GradleProperties.fromFile or GradleProperties.fromPath is used to create instance, then that file will be used by default to write back on it.

To save properties to a different file, pass file param. file has precedence over source file.

throws FileSystemException if no file is provided.

Implementation

Future<void> save([File? file]) async {
  final outputFile = file ?? _file;
  if (outputFile == null) {
    throw FileSystemException('Properties file not found');
  }
  final sink = outputFile.openWrite();
  _props.forEach((key, value) => sink.writeln('$key=$value'));
  await sink.close();
}