toFile method

Future<OutputInfo> toFile(
  1. Object file, {
  2. ImageFormat? format,
  3. CodecRegistry? registry,
  4. CancellationToken? cancellationToken,
})

Writes encoded output to a file path or File.

Implementation

Future<OutputInfo> toFile(
  Object file, {
  ImageFormat? format,
  CodecRegistry? registry,
  CancellationToken? cancellationToken,
}) {
  final resolved = switch (file) {
    final File value => value,
    final String value => File(value),
    _ => throw ArgumentError.value(file, 'file', 'Expected a File or path.'),
  };
  return writeToFile(
    resolved,
    format: format,
    registry: registry,
    cancellationToken: cancellationToken,
  );
}