rich_multimedia library

A model-agnostic Flutter kit for displaying mixed media (images, videos, audio, PDFs, and generic files) in a carousel and a full-screen viewer, with optional screenshot protection and a built-in download flow.

See the README for usage examples of MediaCarousel and MultiMediaItem — the two widgets most apps need — plus the lower-level pieces exported here for building a custom layout.

Classes

FilePlaceholder
Generic "this is a file" tile: an icon derived from the file's extension plus its name, centered. Used as the fallback for any media kind this package doesn't render inline (a .docx, .zip, etc.) and as the error fallback when a PDF fails to load.
ImageItemWidget
One pinch-to-zoom image page inside MediaFullViewer. Renders from the local filesystem when mediaUrl is a local path, otherwise loads it as a cached network image with a shimmer placeholder.
InMemoryAudioPlayer
An inline audio player — streams url (network or local file path, anything just_audio's setUrl accepts) and renders a compact icon + optional scrubber + play/pause button that scales to whatever box it's given.
InMemoryPdfViewer
Downloads url once, caches the bytes on disk (keyed by a hash of the URL, capped at 50MB total and evicted after 7 days), and renders it with flutter_pdfview. Falls back to a cached copy if a re-fetch fails, and to a plain FilePlaceholder if nothing could be loaded at all.
LocalVideoPreview
A small (143x143) square thumbnail for a video that lives on the local filesystem — a play-button overlay and the duration badge, tap to play inline or run onTap instead (e.g. to open the full viewer).
MediaCarousel
A dark, rounded media carousel — a swipeable page view of mediaUrls (each rendered by MultiMediaItem, so image/video/audio/pdf/other all just work) with prev/next arrows and a footer bar (dot indicator, counter, caption, download button).
MediaCarouselFooter
The dark footer bar under MediaCarousel's page view: dot indicator + "X of N" counter, an optional caption line, and either a download button or a locked (greyed-out, tooltip-explained) placeholder for it.
MediaClassifier
Static helpers for classifying a media URL/path and deriving display info (file name, icon, human-readable size) from it. None of this reads the file itself — it's all extension-based, same as the app code this was extracted from.
MediaDotsIndicator
Dot-indicator row for a media carousel — capped at 3 visible dots with an ellipsis dot standing in for the rest once there are more pages than that. Already model-agnostic in the app this was extracted from (it had already been pulled out once there to stop a near-identical dot-drawing loop from being reimplemented inline wherever a plain dot row — no lock/download/caption bar — was needed), so it ports over unchanged beyond the import.
MediaDownloader
Downloads a media URL and either saves it to the device's gallery (images/videos) or to the app's documents folder with an "Open" action (anything else — PDFs, docs, etc.), showing progress in a bottom sheet the whole way.
MediaFullViewer
Full-screen, swipeable viewer for a list of media URLs — images (pinch to zoom), videos (play/pause/mute/scrub, auto-pauses off-screen pages), audio, PDFs, and a generic file fallback, all dispatched through MediaClassifier. This is what MultiMediaItem opens on tap; use MediaFullViewer.show directly if you want to open it from your own tap handler without going through that widget.
MediaNavArrow
A small circular prev/next button used both inside MediaCarousel (over the inline carousel) and inside MediaFullViewer (over the full-screen pager) — the original app had two near-identical widgets for this (ArrowButton and a second one used only by the full viewer); this is the one shared version, with size exposed so each call site can pick its own scale instead of needing a second class.
MultiMediaItem
A single media tile that renders the right preview for whatever url is (image / video / audio / pdf / other file), and opens MediaFullViewer on tap — the one widget most apps actually reach for.
NetworkVideoPreview
A small (143x143) square thumbnail for a network video — same shape as LocalVideoPreview but for a remote URL, with its own loading spinner while the stream initializes.
ScreenshotProtection
Thin wrapper around the no_screenshot plugin, tracking whether protection is currently on so enabling/disabling it is idempotent (the underlying plugin call is a no-op either way, but this avoids firing it redundantly if, say, two media tiles are opened and closed in quick succession).
VideoItemWidget
One video page inside MediaFullViewer. Dumb by design — all the state (controller, play/pause, progress) lives in the viewer itself; this widget just renders whatever it's handed, including the "still loading" state.
VideoPreviewWidget
A full-width network-video preview tile with its own inline play/pause, mute, and "open full viewer" controls. Auto-pauses after 15 seconds (a deliberate "preview, not full playback" cap — open the full viewer for longer than that) and auto-pauses when it scrolls out of view.

Enums

MediaKind
What kind of media a URL or local file path points to, plus the extension-based classification every widget in this package relies on.