VideoViewerScreen class

A full-screen video player with a close button, a title, and Share and Download actions.

Push it onto the navigation stack as its own route — for example from a tapped VideoThumbnailTile — rather than embedding it in a page; use VideoViewerWidget directly for an inline player. It always renders on a black canvas with white controls, regardless of the app's theme.

Navigator.of(context).push(
  MaterialPageRoute(
    fullscreenDialog: true,
    builder: (_) => VideoViewerScreen(
      source: VideoSource.uri(Uri.parse('https://example.com/clip.mp4')),
      title: 'clip.mp4',
      onShare: (sharePositionOrigin) => share(sharePositionOrigin),
      onDownload: download,
    ),
  ),
);

Actions

Provide onShare and/or onDownload to enable the corresponding actions; a null callback hides its action. The platform's usual one gets an app bar button — Share on mobile and desktop, Download on web — and the other goes in the overflow menu, followed by your own entries from actions. The overflow menu is hidden when it would be empty. Sharing and saving are left to the consumer so this package carries no platform plugins beyond the player.

Closing

The close button pops the route, and is left out when there is no route to go back to. Supply onClose when the screen isn't a pushed route — for example a deep-linked page — to show the button and decide where it goes.

Inheritance

Constructors

VideoViewerScreen({Key? key, required VideoSource source, String? title, VoidCallback? onClose, VideoViewerShareCallback? onShare, VoidCallback? onDownload, List<VideoViewerAction> actions = const [], bool autoPlay = true, bool looping = false, Widget errorBuilder(BuildContext context, Object error)?, String errorMessage = 'Could not load video', VoidCallback? onExitFullScreen})
Creates a VideoViewerScreen.
const

Properties

actions → List<VideoViewerAction>
Additional actions, shown in order at the end of the overflow menu.
final
autoPlay → bool
Whether playback starts as soon as the video has loaded. Defaults to true, since opening the screen is already a request to watch. See VideoViewerWidget.autoPlay.
final
errorBuilder → Widget Function(BuildContext context, Object error)?
Optional builder for an error UI shown in place of the video when it fails to load.
final
errorMessage → String
Message shown by the default error UI.
final
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
looping → bool
Whether the video starts again from the beginning when it ends.
final
onClose → VoidCallback?
Called when the user taps the close button. If null, the button pops the route, and is hidden when there is no route to go back to.
final
onDownload → VoidCallback?
Called when the user chooses Download. If null, Download is hidden.
final
onExitFullScreen → VoidCallback?
Called when the player's own full-screen mode closes. See VideoViewerWidget.onExitFullScreen.
final
onShare → VideoViewerShareCallback?
Called when the user chooses Share. If null, Share is hidden.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
source → VideoSource
The video to play.
final
title → String?
Title shown in the app bar, typically the file name. Long titles are truncated with an ellipsis.
final

Methods

build(BuildContext context) → Widget
Describes the part of the user interface represented by this widget.
override
createElement() → StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited