http_cache_stream library

A Flutter package that simultaneously downloads, caches, and streams remote content.

By creating a local HTTP server, http_cache_stream supports virtually any plugin that streams from web links. Unlike traditional caching solutions, it works while the file is still downloading - allowing immediate playback of media files.

Features:

  • Simultaneous download and streaming
  • Persistent caching for offline playback
  • Range request support (seeking)
  • Resumable downloads
  • Custom header configuration

Classes

CacheConfiguration
CachedResponseHeaders
CacheFiles
CacheMetadata
Metadata for a cached file.
CacheResetException
CacheSourceChangedException
GlobalCacheConfig
A configuration class for HttpCacheManager.
HttpCacheManager
Manages the local HTTP server and HttpCacheStream instances.
HttpCacheServer
A server that redirects requests to a source and automatically creates HttpCacheStream instances.
HttpCacheStream
A stream that handles downloading, caching, and serving content.
HttpRange
HttpRangeRequest
HttpRangeResponse
IntRange
A class that represents a range of exclusive integers
InvalidCacheException
InvalidCacheLengthException
StreamCacheConfig
Cache configuration for a single HttpCacheStream.
StreamResponse
Represents a response from the cache manager.

Functions

defaultCacheFileResolver(Directory cacheDirectory, Uri sourceUrl) File
Default cache file resolver. Generates a file path based on the URL structure, with sanitization to ensure valid file names and paths. If the generated path exceeds platform limits, it falls back to a hash-based file name.
hashCacheFileResolver(Directory cacheDirectory, Uri url) File

Typedefs

CacheFileResolver = File Function(Directory cacheDirectory, Uri sourceUrl)
HttpCacheStreamCreatedCallback = void Function(HttpCacheStream stream)