downloadAll method

Future<void> downloadAll({
  1. void onProgress(
    1. double
    )?,
})

Download all fonts. Reports progress via onProgress (0.0 → 1.0).

Implementation

Future<void> downloadAll({void Function(double)? onProgress}) async {
  final totalBundles = (_totalPages / _bundleSize).ceil();
  int completed = 0;

  for (int bundleStart = 1;
      bundleStart <= _totalPages;
      bundleStart += _bundleSize) {
    final bundleEnd =
        (bundleStart + _bundleSize - 1).clamp(1, _totalPages);
    final bundleName =
        'qfc4_pages_${bundleStart.toString().padLeft(3, '0')}_${bundleEnd.toString().padLeft(3, '0')}.zip';
    await _downloadAndExtractBundle(bundleName);
    completed++;
    onProgress?.call(completed / totalBundles);
  }
}