YPlayer class

A customizable YouTube video player widget.

This widget provides a flexible way to embed and control YouTube videos in a Flutter application, with options for customization and event handling.

Inheritance

Constructors

YPlayer.new({Key? key, required String youtubeUrl, double? aspectRatio, bool autoPlay = true, Widget? placeholder, Widget? loadingWidget, Widget? errorWidget, YPlayerStateCallback? onStateChanged, YPlayerProgressCallback? onProgressChanged, dynamic onControllerReady(YPlayerController controller)?, Color? color, dynamic onEnterFullScreen()?, dynamic onExitFullScreen()?, EdgeInsets? seekBarMargin, EdgeInsets? fullscreenSeekBarMargin, EdgeInsets? bottomButtonBarMargin, EdgeInsets? fullscreenBottomButtonBarMargin, bool chooseBestQuality = true})
Constructs a YPlayer widget.
const

Properties

aspectRatio double?
The aspect ratio of the video player. If null, defaults to 16:9.
final
autoPlay bool
Whether the video should start playing automatically when loaded.
final
bottomButtonBarMargin EdgeInsets?
The margin around the bottom button bar.
final
chooseBestQuality bool
Whether to choose the best quality automatically.
final
color Color?
The primary color for the player's UI elements.
final
errorWidget Widget?
A widget to display if there's an error loading the video.
final
fullscreenBottomButtonBarMargin EdgeInsets?
The margin around the bottom button bar in fullscreen mode.
final
fullscreenSeekBarMargin EdgeInsets?
The margin around the seek bar in fullscreen mode.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
loadingWidget Widget?
A widget to display while the video is loading.
final
onControllerReady → dynamic Function(YPlayerController controller)?
A callback that is triggered when the player controller is ready.
final
onEnterFullScreen → dynamic Function()?
A callback that is triggered when the player enters full screen mode.
final
onExitFullScreen → dynamic Function()?
A callback that is triggered when the player exits full screen mode.
final
onProgressChanged YPlayerProgressCallback?
A callback that is triggered when the video's playback progress changes.
final
onStateChanged YPlayerStateCallback?
A callback that is triggered when the player's state changes.
final
placeholder Widget?
A widget to display while the video is not yet loaded.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
seekBarMargin EdgeInsets?
The margin around the seek bar.
final
youtubeUrl String
The URL of the YouTube video to play.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() YPlayerState
Creates the mutable state for this widget at a given location in the tree.
override
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