startForeground method Null safety

Stream<DownloadProgress> startForeground(
  1. {required DownloadableRegion region,
  2. FMTCTileProviderSettings? tileProviderSettings,
  3. bool disableRecovery = false,
  4. DownloadBufferMode bufferMode = DownloadBufferMode.disabled,
  5. int? bufferLimit}
)

Download a specified DownloadableRegion in the foreground

To check the number of tiles that need to be downloaded before using this function, use check.

Unless otherwise specified in disableRecovery, a recovery session is started.

bufferMode and bufferLimit control how this download will use buffering. For information about buffering, and it's advantages and disadvantages, see this docs page. Also see DownloadBufferMode's documentation.

Note that these defaults may not be suitable for your user's devices, and you should adjust them to be suitable to your usecase.

Streams a DownloadProgress object containing statistics and information about the download's progression status.

Implementation

Stream<DownloadProgress> startForeground({
  required DownloadableRegion region,
  FMTCTileProviderSettings? tileProviderSettings,
  bool disableRecovery = false,
  DownloadBufferMode bufferMode = DownloadBufferMode.disabled,
  int? bufferLimit,
}) async* {
  _recoveryId = DateTime.now().millisecondsSinceEpoch;

  if (!disableRecovery) {
    await FMTC.instance.rootDirectory.recovery._start(
      id: _recoveryId!,
      storeName: _storeDirectory.storeName,
      region: region,
    );
  }

  yield* _startDownload(
    tileProviderSettings: tileProviderSettings,
    region: region,
    tiles: await _generateTilesComputer(region),
    bufferMode: bufferMode,
    bufferLimit: bufferLimit,
  );
}