saveNetwork abstract method

Stream<SaveProgress> saveNetwork({
  1. required String url,
  2. required String fileName,
  3. required FileType fileType,
  4. Map<String, String>? headers,
  5. Duration timeout = const Duration(seconds: 60),
  6. SaveLocation? saveLocation,
  7. String? subDir,
  8. ConflictResolution conflictResolution = ConflictResolution.autoRename,
})

Downloads from url and saves to device storage with progress streaming.

Platforms: Android · iOS · macOS · Windows · Linux · Web

Downloaded natively to avoid double storage:

  • Android: streams directly to MediaStore (zero temp files)

  • iOS Documents: downloads directly to target path

  • iOS Photos: temp → Photos Library → delete temp

  • headers: Optional HTTP headers for the request

  • timeout: Network timeout (default 60s)

  • saveLocation: Where to save the file (platform-specific, optional)

  • subDir: Optional subdirectory within the standard save location

  • conflictResolution: How to handle filename conflicts

Yields SaveProgress events during save operation.

Throws NetworkException if the download fails.

Implementation

Stream<SaveProgress> saveNetwork({
  required String url,
  required String fileName,
  required FileType fileType,
  Map<String, String>? headers,
  Duration timeout = const Duration(seconds: 60),
  SaveLocation? saveLocation,
  String? subDir,
  ConflictResolution conflictResolution = ConflictResolution.autoRename,
});