### initState Implementation Example Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieState/initState.html Implement initState to perform initial setup. Always call super.initState() first. Subscribe to controllers or initialize notifiers as needed. ```dart @override void initState() { super.initState(); widget.controller.addListener(listener); notifier = PlayerNotifier.init(); } ``` -------------------------------- ### Start At Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController-class.html Specifies the initial playback position for the video. ```APIDOC ## startAt ### Description Start video at a certain position. ### Type `Duration?` ``` -------------------------------- ### Full Screen By Default Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController-class.html Configures the player to start in fullscreen mode when playback begins. ```APIDOC ## fullScreenByDefault ### Description Defines if the player will start in fullscreen when play is pressed. ### Type `bool` ``` -------------------------------- ### Placeholder Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController-class.html A widget displayed before the video is initialized or starts playing. ```APIDOC ## placeholder ### Description The placeholder is displayed underneath the Video before it is initialized or played. ### Type `Widget?` ``` -------------------------------- ### Install Chewie and video_player Source: https://pub.dev/documentation/chewie/1.14.0/index.html Add Chewie and video_player to your pubspec.yaml file to include them as dependencies in your Flutter project. ```yaml dependencies: chewie: video_player: ``` -------------------------------- ### Implement createState for MaterialControls Source: https://pub.dev/documentation/chewie/1.14.0/chewie/MaterialControls/createState.html This is an example implementation of the createState method for a specific widget, _MaterialControlsState. Ensure the return type matches the widget. ```dart @override State createState() { return _MaterialControlsState(); } ``` -------------------------------- ### Auto Play Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController-class.html Configures the video player to start playing the video automatically as soon as it is displayed. ```APIDOC ## autoPlay ### Description Play the video as soon as it's displayed. ### Type `bool` ``` -------------------------------- ### Show Subtitles Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController-class.html Determines whether subtitles should be displayed by default when the video starts. ```APIDOC ## showSubtitles ### Description Determines whether subtitles should be shown by default when the video starts. ### Type `bool` (getter/setter pair) ``` -------------------------------- ### Subtitle Constructor Implementation Source: https://pub.dev/documentation/chewie/1.14.0/chewie/Subtitle/Subtitle.html This is the implementation of the Subtitle constructor, which requires index, start, end, and text. ```dart Subtitle({ required this.index, required this.start, required this.end, required this.text, }); ``` -------------------------------- ### Get isFullScreen Property Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController/isFullScreen.html Retrieve the current fullscreen state of the video player. This getter returns a boolean value. ```dart bool get isFullScreen => _isFullScreen; ``` -------------------------------- ### togglePause Method Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController/togglePause.html This method toggles between playing and pausing the media. If the media is currently playing, it will be paused. If it is paused, it will start playing. ```APIDOC ## togglePause() ### Description Toggles the playback state of the media. ### Method Signature `void togglePause()` ### Implementation Details Internally, this method checks the `isPlaying` state. If `isPlaying` is true, it calls the `pause()` method. Otherwise, it calls the `play()` method. ``` -------------------------------- ### fullScreenByDefault Property Declaration Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController/fullScreenByDefault.html This property defines if the player will start in fullscreen when play is pressed. It is a final boolean value. ```dart final bool fullScreenByDefault; ``` -------------------------------- ### Check if Controller is Full Screen Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieState/isControllerFullScreen.html Use this getter to determine if the video player is currently in full-screen mode. No setup is required beyond having an instance of the Chewie controller. ```dart bool get isControllerFullScreen => widget.controller.isFullScreen; ``` -------------------------------- ### Add Subtitles to ChewieController Source: https://pub.dev/documentation/chewie/1.14.0/index.html Configure ChewieController to display custom subtitles with specified start and end times, and text. The `showSubtitles` flag must be true to enable them. A `subtitleBuilder` can be used for custom rendering. ```dart ChewieController( videoPlayerController: _videoPlayerController, autoPlay: true, looping: true, subtitle: Subtitles([ Subtitle( index: 0, start: Duration.zero, end: const Duration(seconds: 10), text: 'Hello from subtitles', ), Subtitle( index: 1, start: const Duration(seconds: 10), end: const Duration(seconds: 20), text: 'What’s up? :) ), ]), showSubtitles: true, // Automatically display subtitles subtitleBuilder: (context, subtitle) => Container( padding: const EdgeInsets.all(10.0), child: Text( subtitle, style: const TextStyle(color: Colors.white), ), ), ); ``` -------------------------------- ### Declare Final Duration Start Property Source: https://pub.dev/documentation/chewie/1.14.0/chewie/Subtitle/start.html This snippet shows the declaration of the 'start' property as a final Duration. It is typically used to mark the beginning of a time interval. ```dart final Duration start; ``` -------------------------------- ### Show Controls On Initialize Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController-class.html Determines if the video player controls should be visible immediately upon initialization. ```APIDOC ## showControlsOnInitialize ### Description Wether or not to show the controls when initializing the widget. ### Type `bool` ``` -------------------------------- ### play method Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController/play.html Initiates video playback. ```APIDOC ## play() ### Description Starts playing the video. ### Method `play()` ### Parameters None ### Request Example ```dart chewieController.play(); ``` ### Response None ``` -------------------------------- ### MaterialVideoProgressBar Constructor Source: https://pub.dev/documentation/chewie/1.14.0/chewie/MaterialVideoProgressBar/MaterialVideoProgressBar.html Initializes a new instance of the MaterialVideoProgressBar widget. ```APIDOC ## MaterialVideoProgressBar Constructor ### Description Initializes a new instance of the MaterialVideoProgressBar widget. ### Parameters #### Positional Parameters - **controller** (VideoPlayerController) - Required - The video player controller to associate with the progress bar. #### Optional Parameters - **height** (double) - Optional - The total height of the progress bar widget. Defaults to `kToolbarHeight`. - **barHeight** (double) - Optional - The thickness of the progress bar itself. Defaults to 10. - **handleHeight** (double) - Optional - The height of the draggable handle on the progress bar. Defaults to 6. - **colors** (ChewieProgressColors?) - Optional - Customizes the colors of the progress bar. - **onDragEnd** (dynamic?) - Optional - Callback function invoked when the user finishes dragging the progress bar handle. - **onDragStart** (dynamic?) - Optional - Callback function invoked when the user starts dragging the progress bar handle. - **onDragUpdate** (dynamic?) - Optional - Callback function invoked when the user updates the position of the progress bar handle during a drag. - **key** (Key?) - Optional - A unique key for the widget. - **draggableProgressBar** (bool) - Optional - Enables or disables the draggable functionality of the progress bar. Defaults to true. ``` -------------------------------- ### Build Method Implementation Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieState/build.html This is the standard implementation of the build method for ChewieState. It sets up the necessary providers for the controller and player state, and then renders the player with controls. ```dart @override Widget build(BuildContext context) { return ChewieControllerProvider( controller: widget.controller, child: ChangeNotifierProvider.value( value: notifier, builder: (context, w) => const PlayerWithControls(), ), ); } ``` -------------------------------- ### Initialize and Use Chewie Player Source: https://pub.dev/documentation/chewie/1.14.0/index.html Initialize VideoPlayerController and ChewieController, then use the Chewie widget for video playback. Remember to dispose of the controllers when they are no longer needed. ```dart import 'package:chewie/chewie.dart'; import 'package:video_player/video_player.dart'; final videoPlayerController = VideoPlayerController.networkUrl(Uri.parse( 'https://flutter.github.io/assets-for-api-docs/assets/videos/butterfly.mp4')); await videoPlayerController.initialize(); final chewieController = ChewieController( videoPlayerController: videoPlayerController, autoPlay: true, looping: true, ); final playerWidget = Chewie( controller: chewieController, ); ``` ```dart @override void dispose() { videoPlayerController.dispose(); chewieController.dispose(); super.dispose(); } ``` -------------------------------- ### MaterialVideoProgressBar Methods Source: https://pub.dev/documentation/chewie/1.14.0/chewie/MaterialVideoProgressBar-class.html Provides methods for building and managing the widget's lifecycle. ```APIDOC ## MaterialVideoProgressBar Methods ### build - **Signature**: `build(BuildContext context) → Widget` - **Description**: Describes the part of the user interface represented by this widget. This method is overridden to return the widget's UI structure. ``` -------------------------------- ### ChewieController Methods Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController-class.html Methods for controlling video playback, fullscreen, and managing listeners. ```APIDOC ## addListener(VoidCallback listener) ### Description Register a closure to be called when the object changes. ### Method void ### Parameters - **listener** (VoidCallback) - The callback function to register. ``` ```APIDOC ## dispose() ### Description Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded. ### Method void ``` ```APIDOC ## enterFullScreen() ### Description Enter fullscreen mode for the video player. ### Method void ``` ```APIDOC ## exitFullScreen() ### Description Exit fullscreen mode for the video player. ### Method void ``` ```APIDOC ## pause() ### Description Pauses the video playback. ### Method Future ``` ```APIDOC ## play() ### Description Plays the video playback. ### Method Future ``` ```APIDOC ## removeListener(VoidCallback listener) ### Description Remove a previously registered closure from the list of closures that are notified when the object changes. ### Method void ### Parameters - **listener** (VoidCallback) - The callback function to remove. ``` ```APIDOC ## seekTo(Duration moment) ### Description Seeks the video to a specific moment in time. ### Method Future ### Parameters - **moment** (Duration) - The duration to seek to. ``` ```APIDOC ## setLooping(bool looping) ### Description Sets whether the video should loop. ### Method Future ### Parameters - **looping** (bool) - Whether to enable looping. ``` ```APIDOC ## setSubtitle(List newSubtitle) ### Description Sets a new list of subtitles for the video. ### Method void ### Parameters - **newSubtitle** (List) - The new list of subtitles. ``` ```APIDOC ## setVolume(double volume) ### Description Sets the volume of the video player. ### Method Future ### Parameters - **volume** (double) - The desired volume level (0.0 to 1.0). ``` ```APIDOC ## toggleFullScreen() ### Description Toggles between fullscreen and normal screen mode. ### Method void ``` ```APIDOC ## togglePause() ### Description Toggles between playing and paused state. ### Method void ``` -------------------------------- ### Auto Initialize Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController-class.html Determines whether the video player should initialize automatically when the widget is created. ```APIDOC ## autoInitialize ### Description Initialize the Video on Startup. This will prep the video for playback. ### Type `bool` ``` -------------------------------- ### Subtitles Constructor Source: https://pub.dev/documentation/chewie/1.14.0/chewie/Subtitles-class.html Initializes a new instance of the Subtitles class with a list of subtitle objects. ```APIDOC ## Subtitles Constructor ### Description Initializes a new instance of the Subtitles class. ### Signature Subtitles(List subtitle) ``` -------------------------------- ### Get ChewieController Instance Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController/of.html Use this method to obtain the `ChewieController` from the widget tree. Ensure a `ChewieControllerProvider` is an ancestor of the `BuildContext` provided. ```dart static ChewieController of(BuildContext context) { final chewieControllerProvider = context .dependOnInheritedWidgetOfExactType()!; return chewieControllerProvider.controller; } ``` -------------------------------- ### MaterialVideoProgressBar Constructor Source: https://pub.dev/documentation/chewie/1.14.0/chewie/MaterialVideoProgressBar-class.html Initializes a new instance of the MaterialVideoProgressBar class. It requires a VideoPlayerController and accepts optional parameters for customization. ```APIDOC ## MaterialVideoProgressBar Constructor ### Description Initializes a new instance of the MaterialVideoProgressBar class. ### Parameters - **controller** (VideoPlayerController) - Required - The controller for the video player. - **height** (double) - Optional - The overall height of the progress bar widget. Defaults to `kToolbarHeight`. - **barHeight** (double) - Optional - The height of the progress bar itself. Defaults to 10. - **handleHeight** (double) - Optional - The height of the draggable handle. Defaults to 6. - **colors** (ChewieProgressColors?) - Optional - Customizes the colors of the progress bar. - **onDragEnd** (dynamic Function()?) - Optional - Callback function invoked when the user finishes dragging the progress bar. - **onDragStart** (dynamic Function()?) - Optional - Callback function invoked when the user starts dragging the progress bar. - **onDragUpdate** (dynamic Function()?) - Optional - Callback function invoked when the user updates the drag position. - **key** (Key?) - Optional - A unique key for the widget. - **draggableProgressBar** (bool) - Optional - Enables or disables the draggable functionality of the progress bar. Defaults to true. ``` -------------------------------- ### Get Subtitles by Position Source: https://pub.dev/documentation/chewie/1.14.0/chewie/Subtitles/getByPosition.html This implementation filters a list of subtitles to find those active at the given duration. It handles null subtitle entries gracefully. ```dart List getByPosition(Duration position) { final found = subtitle.where((item) { if (item != null) { return position >= item.start && position <= item.end; } return false; }).toList(); return found; } ``` -------------------------------- ### Get isEmpty Property Source: https://pub.dev/documentation/chewie/1.14.0/chewie/Subtitles/isEmpty.html Returns true if the subtitle string is empty, false otherwise. This property is a direct delegate to the underlying string's isEmpty. ```dart bool get isEmpty => subtitle.isEmpty; ``` -------------------------------- ### MaterialDesktopControls Constructor Source: https://pub.dev/documentation/chewie/1.14.0/chewie/MaterialDesktopControls-class.html Initializes a new instance of the MaterialDesktopControls class. ```APIDOC ## MaterialDesktopControls const MaterialDesktopControls({bool showPlayButton = true, Key? key}) ### Description Initializes a new instance of the MaterialDesktopControls class. ### Parameters - **showPlayButton** (bool) - Optional - Defaults to true. Determines if the play button should be shown. - **key** (Key?) - Optional - Controls how one widget replaces another widget in the tree. ``` -------------------------------- ### Get isPlaying Status Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController/isPlaying.html Access the `isPlaying` getter to determine if the video playback is active. This property directly reflects the state of the underlying video player. ```dart bool get isPlaying => videoPlayerController.value.isPlaying; ``` -------------------------------- ### Define a Single Subtitle Source: https://pub.dev/documentation/chewie/1.14.0/index.html Create a `Subtitle` object to define a single subtitle entry. This includes a unique index, start and end durations, and the text to be displayed. ```dart Subtitle( index: 0, start: Duration.zero, end: const Duration(seconds: 10), text: 'Hello from subtitles', ), ``` -------------------------------- ### setVolume Method Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController/setVolume.html Sets the volume of the video player. The volume should be a double between 0.0 and 1.0. ```APIDOC ## setVolume ### Description Sets the volume of the video player. ### Method Signature `Future setVolume(double volume)` ### Parameters #### Path Parameters - **volume** (double) - Required - The desired volume level, between 0.0 and 1.0. ``` -------------------------------- ### enterFullScreen Method Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController/enterFullScreen.html This method is used to enable full-screen mode for the Chewie player. It updates the internal state and notifies listeners of the change. ```APIDOC ## enterFullScreen() ### Description Enables full-screen mode for the Chewie player. ### Method Signature `void enterFullScreen()` ### Implementation Details This method sets an internal flag `_isFullScreen` to true and then calls `notifyListeners()` to inform any observers of the state change. ``` -------------------------------- ### Subtitle Constructor Source: https://pub.dev/documentation/chewie/1.14.0/chewie/Subtitle-class.html Initializes a new instance of the Subtitle class. ```APIDOC ## Subtitle Constructor ### Description Creates a new Subtitle object. ### Parameters - **index** (int) - Required - The index of the subtitle. - **start** (Duration) - Required - The start time of the subtitle. - **end** (Duration) - Required - The end time of the subtitle. - **text** (dynamic) - Required - The text content of the subtitle. ``` -------------------------------- ### showControlsOnInitialize Property Declaration Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController/showControlsOnInitialize.html This property controls the initial visibility of the video player controls. Set to true to show controls on load, false to hide them. ```dart final bool showControlsOnInitialize; ``` -------------------------------- ### Override toString Method for Subtitle Source: https://pub.dev/documentation/chewie/1.14.0/chewie/Subtitle/toString.html Overrides the default toString method to provide a detailed string representation of the Subtitle object, including its index, start and end times, and text content. Useful for debugging. ```dart @override String toString() { return 'Subtitle(index: $index, start: $start, end: $end, text: $text)'; } ``` -------------------------------- ### Subtitle copyWith Implementation Source: https://pub.dev/documentation/chewie/1.14.0/chewie/Subtitle/copyWith.html This method creates a new Subtitle object, optionally updating its index, start time, end time, and text. If a parameter is not provided, the existing value from the current Subtitle instance is used. ```dart Subtitle copyWith({ int? index, Duration? start, Duration? end, dynamic text, }) { return Subtitle( index: index ?? this.index, start: start ?? this.start, end: end ?? this.end, text: text ?? this.text, ); } ``` -------------------------------- ### OptionItem Constructor Implementation Source: https://pub.dev/documentation/chewie/1.14.0/chewie/OptionItem/OptionItem.html This code shows the implementation of the OptionItem constructor, which initializes the widget with required and optional properties. ```dart OptionItem({ required this.onTap, required this.iconData, required this.title, this.subtitle, }); ``` -------------------------------- ### Implement setVolume Method Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController/setVolume.html This snippet shows the implementation of the setVolume method, which calls the underlying video player controller to set the volume. ```dart Future setVolume(double volume) async { await videoPlayerController.setVolume(volume); } ``` -------------------------------- ### Override operator == for Subtitle Source: https://pub.dev/documentation/chewie/1.14.0/chewie/Subtitle/operator_equals.html This implementation checks for identity first, then type, and finally compares relevant properties (index, start, end, text) for equality. Ensure the `hashCode` method is also overridden when overriding `==`. ```dart @override bool operator ==(Object other) { if (identical(this, other)) return true; return other is Subtitle && other.index == index && other.start == start && other.end == end && other.text == text; } ``` -------------------------------- ### operator == Source: https://pub.dev/documentation/chewie/1.14.0/chewie/Subtitle/operator_equals.html The equality operator (==) is overridden to compare two Subtitle objects. It returns true if both objects are of type Subtitle and all their corresponding properties (index, start, end, text) are equal. It also includes an optimization to return true immediately if the objects are the same instance. ```APIDOC ## operator == ### Description Overrides the default equality check for the Subtitle class. This method determines if two Subtitle objects are considered equal. ### Method `bool operator ==(Object other)` ### Parameters - **other** (Object) - The object to compare with the current Subtitle instance. ### Response - **bool** - Returns `true` if the objects are equal, `false` otherwise. ### Implementation Details The method first checks if the objects are identical. If not, it verifies if `other` is a `Subtitle` instance and then compares the `index`, `start`, `end`, and `text` properties of both objects. For the equality to be true, all these properties must match. ### Example ```dart Subtitle sub1 = Subtitle(index: 1, start: Duration.zero, end: Duration(seconds: 1), text: 'Hello'); Subtitle sub2 = Subtitle(index: 1, start: Duration.zero, end: Duration(seconds: 1), text: 'Hello'); Subtitle sub3 = Subtitle(index: 2, start: Duration.zero, end: Duration(seconds: 1), text: 'Hello'); print(sub1 == sub2); // Output: true print(sub1 == sub3); // Output: false ``` ``` -------------------------------- ### Subtitle Constructor Source: https://pub.dev/documentation/chewie/1.14.0/chewie/Subtitle/Subtitle.html Initializes a new Subtitle object with essential timing and text information. ```APIDOC ## Subtitle Constructor ### Description Initializes a new Subtitle object with essential timing and text information. ### Parameters #### Constructor Parameters - **index** (int) - Required - A unique identifier for the subtitle. - **start** (Duration) - Required - The time at which the subtitle should start. - **end** (Duration) - Required - The time at which the subtitle should end. - **text** (dynamic) - Required - The content of the subtitle. ### Implementation ```dart Subtitle({ required this.index, required this.start, required this.end, required this.text, }); ``` ``` -------------------------------- ### ChewieControllerProvider Constructor Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieControllerProvider/ChewieControllerProvider.html The ChewieControllerProvider constructor takes a key, a ChewieController, and a child widget. The controller is required and will be provided to descendant widgets. ```APIDOC ## ChewieControllerProvider Constructor ### Description Provides a `ChewieController` to its descendants. ### Parameters #### Path Parameters - **key** (Key?) - Optional - The key for the widget. - **controller** (ChewieController) - Required - The `ChewieController` to provide. - **child** (Widget) - Required - The child widget to be managed by the provider. ``` -------------------------------- ### ChewieControllerProvider Constructor Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieControllerProvider-class.html Initializes a new instance of the ChewieControllerProvider widget. It requires a controller and a child widget. ```APIDOC ## ChewieControllerProvider Constructor ### Description Initializes a new instance of the ChewieControllerProvider widget. It requires a controller and a child widget. ### Parameters #### Path Parameters - **controller** (ChewieController) - Required - The ChewieController instance to provide. - **child** (Widget) - Required - The widget below this widget in the tree. ``` -------------------------------- ### systemOverlaysOnEnterFullScreen Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController/systemOverlaysOnEnterFullScreen.html Defines the system overlays visible on entering fullscreen. ```APIDOC ## systemOverlaysOnEnterFullScreen Property ### Description Defines the system overlays visible on entering fullscreen. ### Type List? ### Declaration ```dart final List? systemOverlaysOnEnterFullScreen; ``` ``` -------------------------------- ### Build Method Implementation Source: https://pub.dev/documentation/chewie/1.14.0/chewie/MaterialVideoProgressBar/build.html This method returns a VideoProgressBar widget, configuring it with various properties like controller, height, shadow, colors, drag handlers, and draggable state. It's used to render the progress bar UI. ```dart @override Widget build(BuildContext context) { return VideoProgressBar( controller, barHeight: barHeight, handleHeight: handleHeight, drawShadow: true, colors: colors, onDragEnd: onDragEnd, onDragStart: onDragStart, onDragUpdate: onDragUpdate, draggableProgressBar: draggableProgressBar, ); } ``` -------------------------------- ### systemOverlaysOnExitFullScreen Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController-class.html Defines the system overlays visible on entering fullscreen. ```APIDOC ## systemOverlaysOnExitFullScreen ### Description Defines the system overlays visible on entering fullscreen. ### Type List? ### Final true ``` -------------------------------- ### OptionsTranslation Constructor Source: https://pub.dev/documentation/chewie/1.14.0/chewie/OptionsTranslation/OptionsTranslation.html Initializes a new instance of the OptionsTranslation class with optional text for various buttons. ```APIDOC ## OptionsTranslation constructor ### Description Initializes a new instance of the OptionsTranslation class. ### Parameters #### Named Parameters - **playbackSpeedButtonText** (String?) - Optional - Text for the playback speed button. - **subtitlesButtonText** (String?) - Optional - Text for the subtitles button. - **cancelButtonText** (String?) - Optional - Text for the cancel button. ### Implementation ```dart OptionsTranslation({ this.playbackSpeedButtonText, this.subtitlesButtonText, this.cancelButtonText, }); ``` ``` -------------------------------- ### Enter Full Screen Implementation Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController/enterFullScreen.html Sets the internal full-screen state to true and notifies any listeners of the change. ```dart void enterFullScreen() { _isFullScreen = true; notifyListeners(); } ``` -------------------------------- ### Options Builder Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController-class.html Allows developers to build custom options menus, potentially including default Chewie options. ```APIDOC ## optionsBuilder ### Description Build your own options with default chewieOptions shiped through the builder method. Just add your own options to the Widget you'll build. If you want to hide the chewieOptions, just leave them out from your Widget. ### Type `Future Function(BuildContext context, List chewieOptions)?` ``` -------------------------------- ### CupertinoControls Constructor Source: https://pub.dev/documentation/chewie/1.14.0/chewie/CupertinoControls-class.html Initializes a new instance of the CupertinoControls class. It requires a backgroundColor and iconColor, and optionally accepts a showPlayButton and key. ```APIDOC ## CupertinoControls ### Description Constructs a CupertinoControls widget. ### Parameters - **backgroundColor** (Color) - Required - The background color for the controls. - **iconColor** (Color) - Required - The color for the icons within the controls. - **showPlayButton** (bool) - Optional - Defaults to true. Whether to display the play button. - **key** (Key?) - Optional - An identifier for the widget. ``` -------------------------------- ### MaterialDesktopControls Constructor Source: https://pub.dev/documentation/chewie/1.14.0/chewie/MaterialDesktopControls/MaterialDesktopControls.html The MaterialDesktopControls constructor allows for the creation of desktop control elements with an option to display a play button. ```APIDOC ## MaterialDesktopControls Constructor ### Description Initializes a new instance of the MaterialDesktopControls class. It allows customization of the play button's visibility. ### Parameters - **showPlayButton** (bool) - Optional - Defaults to `true`. If true, the play button will be displayed. - **key** (Key?) - Optional - A unique identifier for the widget. ``` -------------------------------- ### MaterialVideoProgressBar Constructor Signature Source: https://pub.dev/documentation/chewie/1.14.0/chewie/MaterialVideoProgressBar/MaterialVideoProgressBar.html Defines the parameters available for creating a MaterialVideoProgressBar. Includes options for controller, dimensions, colors, drag behavior, and keys. ```dart MaterialVideoProgressBar( 1. VideoPlayerController controller, { 2. double height = kToolbarHeight, 3. double barHeight = 10, 4. double handleHeight = 6, 5. ChewieProgressColors? colors, 6. dynamic onDragEnd()?, 7. dynamic onDragStart()?, 8. dynamic onDragUpdate()?, 9. Key? key, 10. bool draggableProgressBar = true, }) ``` -------------------------------- ### ChewieControllerProvider Constructor Implementation Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieControllerProvider/ChewieControllerProvider.html Provides the implementation for the ChewieControllerProvider constructor, accepting a key, controller, and child widget. ```dart const ChewieControllerProvider({ super.key, required this.controller, required super.child, }); ``` -------------------------------- ### ChewieController Constructor Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController/ChewieController.html The ChewieController constructor allows for extensive customization of the video player. You can configure aspects like video source, playback options, UI elements, and fullscreen behavior. ```APIDOC ## ChewieController constructor ### Description Initializes a new instance of the ChewieController with various customizable options for video playback. ### Parameters #### Constructor Parameters - **videoPlayerController** (VideoPlayerController) - Required - The controller for the underlying video player. - **optionsTranslation** (OptionsTranslation?) - Optional - Translation options for UI elements. - **aspectRatio** (double?) - Optional - The aspect ratio for the video player. - **autoInitialize** (bool) - Optional - Whether to automatically initialize the player (default: false). - **autoPlay** (bool) - Optional - Whether to automatically play the video (default: false). - **draggableProgressBar** (bool) - Optional - Whether the progress bar is draggable (default: true). - **startAt** (Duration?) - Optional - The starting position of the video. - **looping** (bool) - Optional - Whether the video should loop (default: false). - **fullScreenByDefault** (bool) - Optional - Whether to start in fullscreen mode by default (default: false). - **cupertinoProgressColors** (ChewieProgressColors?) - Optional - Progress bar colors for Cupertino style. - **materialProgressColors** (ChewieProgressColors?) - Optional - Progress bar colors for Material style. - **materialSeekButtonFadeDuration** (Duration) - Optional - Fade duration for seek buttons in Material style (default: 300ms). - **materialSeekButtonSize** (double) - Optional - Size of seek buttons in Material style (default: 26). - **placeholder** (Widget?) - Optional - A widget to display before the video loads. - **overlay** (Widget?) - Optional - A widget to display as an overlay on the video. - **showControlsOnInitialize** (bool) - Optional - Whether to show controls when the player initializes (default: true). - **showOptions** (bool) - Optional - Whether to show the options button (default: true). - **optionsBuilder** (Future Function(BuildContext context, List chewieOptions)?) - Optional - A builder function for custom options. - **additionalOptions** (List Function(BuildContext context)?) - Optional - A list of additional options. - **showControls** (bool) - Optional - Whether to show the video controls (default: true). - **transformationController** (TransformationController?) - Optional - Controller for zoom and pan transformations. - **zoomAndPan** (bool) - Optional - Enable zoom and pan functionality (default: false). - **maxScale** (double) - Optional - Maximum scale for zoom and pan (default: 2.5). - **subtitle** (Subtitles?) - Optional - Subtitle configuration. - **showSubtitles** (bool) - Optional - Whether to show subtitles (default: false). - **subtitleBuilder** (Widget Function(BuildContext context, dynamic subtitle)?) - Optional - A builder function for custom subtitle display. - **customControls** (Widget?) - Optional - A custom widget for video controls. - **errorBuilder** (Widget Function(BuildContext context, String errorMessage)?) - Optional - A builder function for displaying errors. - **bufferingBuilder** (WidgetBuilder?) - Optional - A builder function for displaying buffering indicator. - **allowedScreenSleep** (bool) - Optional - Whether to allow the screen to sleep during playback (default: true). - **isLive** (bool) - Optional - Whether the video stream is live (default: false). - **allowFullScreen** (bool) - Optional - Whether to allow fullscreen mode (default: true). - **allowMuting** (bool) - Optional - Whether to allow muting the video (default: true). - **allowPlaybackSpeedChanging** (bool) - Optional - Whether to allow changing playback speed (default: true). - **useRootNavigator** (bool) - Optional - Whether to use the root navigator for fullscreen (default: true). - **playbackSpeeds** (List) - Optional - A list of available playback speeds (default: [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2]). - **systemOverlaysOnEnterFullScreen** (List?) - Optional - System UI overlays to show when entering fullscreen. - **deviceOrientationsOnEnterFullScreen** (List?) - Optional - Device orientations allowed when entering fullscreen. - **systemOverlaysAfterFullScreen** (List) - Optional - System UI overlays to show after exiting fullscreen (default: SystemUiOverlay.values). - **deviceOrientationsAfterFullScreen** (List) - Optional - Device orientations allowed after exiting fullscreen (default: DeviceOrientation.values). - **routePageBuilder** (ChewieRoutePageBuilder?) - Optional - A builder for the fullscreen route page. - **progressIndicatorDelay** (Duration?) - Optional - Delay before showing the progress indicator. - **hideControlsTimer** (Duration) - Optional - Timer duration for hiding controls (default: defaultHideControlsTimer). - **controlsSafeAreaMinimum** (EdgeInsets) - Optional - Minimum safe area padding for controls (default: EdgeInsets.zero). - **pauseOnBackgroundTap** (bool) - Optional - Whether to pause video when tapping the background (default: false). ### Assertion - `playbackSpeeds` must all be greater than 0. ``` -------------------------------- ### OptionsTranslation Constructor Source: https://pub.dev/documentation/chewie/1.14.0/chewie/OptionsTranslation-class.html Initializes an OptionsTranslation object with optional custom text for various buttons. ```APIDOC ## OptionsTranslation Constructor ### Description Initializes an OptionsTranslation object with optional custom text for various buttons. ### Parameters - **playbackSpeedButtonText** (String?) - Optional - Text for the playback speed button. - **subtitlesButtonText** (String?) - Optional - Text for the subtitles button. - **cancelButtonText** (String?) - Optional - Text for the cancel button. ``` -------------------------------- ### Subtitles Constructor Source: https://pub.dev/documentation/chewie/1.14.0/chewie/Subtitles/Subtitles.html The Subtitles class constructor takes a list of nullable Subtitle objects. ```APIDOC ## Subtitles constructor ### Description Initializes a Subtitles object with a list of subtitle entries. ### Parameters #### Path Parameters - **subtitle** (List) - Required - A list of nullable Subtitle objects. ``` -------------------------------- ### listener method Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieState/listener.html This method is called to manage the fullscreen state of the video player. It checks if the controller is in fullscreen mode and updates the UI accordingly, either by pushing a fullscreen widget or popping it. ```APIDOC ## listener() ### Description Manages the fullscreen state transitions for the video player. ### Method Future ### Endpoint N/A (Method within a class) ### Parameters None ### Request Body None ### Response None ### Implementation Details - Checks `isControllerFullScreen` and `_isFullScreen` to determine state. - Uses `_pushFullScreenWidget` to enter fullscreen. - Uses `Navigator.of(context).pop()` to exit fullscreen. - Updates internal state variables like `_wasPlayingBeforeFullScreen` and `_resumeAppliedInFullScreen`. ``` -------------------------------- ### Play Video Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController/play.html Initiates video playback using the video player controller. Ensure the controller is initialized before calling this method. ```dart Future play() async { await videoPlayerController.play(); } ``` -------------------------------- ### Declare and Implement Index Property Source: https://pub.dev/documentation/chewie/1.14.0/chewie/Subtitle/index.html Shows how to declare and implement the 'index' property using 'final'. ```dart final int index; ``` -------------------------------- ### Implement Full Screen Entry Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieState/onEnterFullScreen.html This method is called when the user enters full-screen mode. It hides system overlays and sets preferred device orientations based on the video's aspect ratio or user configurations. ```dart void onEnterFullScreen() { final videoWidth = widget.controller.videoPlayerController.value.size.width; final videoHeight = widget.controller.videoPlayerController.value.size.height; SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); // if (widget.controller.systemOverlaysOnEnterFullScreen != null) { // /// Optional user preferred settings // SystemChrome.setEnabledSystemUIMode( // SystemUiMode.manual, // overlays: widget.controller.systemOverlaysOnEnterFullScreen, // ); // } else { // /// Default behavior // SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: SystemUiOverlay.values); // } if (widget.controller.deviceOrientationsOnEnterFullScreen != null) { /// Optional user preferred settings SystemChrome.setPreferredOrientations( widget.controller.deviceOrientationsOnEnterFullScreen!, ); } else { final isLandscapeVideo = videoWidth > videoHeight; final isPortraitVideo = videoWidth < videoHeight; /// Default behavior /// Video w > h means we force landscape if (isLandscapeVideo) { SystemChrome.setPreferredOrientations([ DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight, ]); } /// Video h > w means we force portrait else if (isPortraitVideo) { SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown, ]); } /// Otherwise if h == w (square video) else { SystemChrome.setPreferredOrientations(DeviceOrientation.values); } } } ``` -------------------------------- ### build method Source: https://pub.dev/documentation/chewie/1.14.0/chewie/MaterialVideoProgressBar/build.html The build method is called by the framework when the widget is inserted into the tree or when its dependencies change. It should return a new widget subtree. ```APIDOC ## build method ### Description Describes the part of the user interface represented by this widget. The framework calls this method when this widget is inserted into the tree in a given BuildContext and when the dependencies of this widget change. This method can potentially be called in every frame and should not have any side effects beyond building a widget. ### Method Signature ```dart @override Widget build(BuildContext context) ``` ### Implementation Details The implementation of this method must only depend on the fields of the widget and any ambient state obtained from the `context`. ### Request Example ```dart @override Widget build(BuildContext context) { return VideoProgressBar( controller, barHeight: barHeight, handleHeight: handleHeight, drawShadow: true, colors: colors, onDragEnd: onDragEnd, onDragStart: onDragStart, onDragUpdate: onDragUpdate, draggableProgressBar: draggableProgressBar, ); } ``` ``` -------------------------------- ### systemOverlaysOnEnterFullScreen Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController-class.html Defines the system overlays visible after exiting fullscreen. ```APIDOC ## systemOverlaysOnEnterFullScreen ### Description Defines the system overlays visible after exiting fullscreen. ### Type List? ### Final true ``` -------------------------------- ### ChewieState Constructors Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieState-class.html Initializes a new instance of the ChewieState class. ```APIDOC ## ChewieState() ### Description Initializes a new instance of the ChewieState class. ### Constructor ChewieState() ``` -------------------------------- ### ChewieController Constructor Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController/ChewieController.html Use this constructor to create an instance of ChewieController. It requires a VideoPlayerController and offers extensive customization for playback, controls, subtitles, and more. Ensure playback speeds are positive. ```dart ChewieController({ required this.videoPlayerController, this.optionsTranslation, this.aspectRatio, this.autoInitialize = false, this.autoPlay = false, this.draggableProgressBar = true, this.startAt, this.looping = false, this.fullScreenByDefault = false, this.cupertinoProgressColors, this.materialProgressColors, this.materialSeekButtonFadeDuration = const Duration(milliseconds: 300), this.materialSeekButtonSize = 26, this.placeholder, this.overlay, this.showControlsOnInitialize = true, this.showOptions = true, this.optionsBuilder, this.additionalOptions, this.showControls = true, this.transformationController, this.zoomAndPan = false, this.maxScale = 2.5, this.subtitle, this.showSubtitles = false, this.subtitleBuilder, this.customControls, this.errorBuilder, this.bufferingBuilder, this.allowedScreenSleep = true, this.isLive = false, this.allowFullScreen = true, this.allowMuting = true, this.allowPlaybackSpeedChanging = true, this.useRootNavigator = true, this.playbackSpeeds = const [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2], this.systemOverlaysOnEnterFullScreen, this.deviceOrientationsOnEnterFullScreen, this.systemOverlaysAfterFullScreen = SystemUiOverlay.values, this.deviceOrientationsAfterFullScreen = DeviceOrientation.values, this.routePageBuilder, this.progressIndicatorDelay, this.hideControlsTimer = defaultHideControlsTimer, this.controlsSafeAreaMinimum = EdgeInsets.zero, this.pauseOnBackgroundTap = false, }) : assert( playbackSpeeds.every((speed) => speed > 0), 'The playbackSpeeds values must all be greater than 0', ) { _initialize(); } ``` -------------------------------- ### ChewieProgressColors Constructor Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieProgressColors-class.html Initializes a ChewieProgressColors object with customizable colors for different parts of the progress bar. ```APIDOC ## ChewieProgressColors Constructor ### Description Initializes a ChewieProgressColors object with customizable colors for the played, buffered, handle, and background elements of the progress bar. ### Parameters - **playedColor** (Color) - Optional - The color for the played portion of the progress bar. Defaults to a semi-transparent red. - **bufferedColor** (Color) - Optional - The color for the buffered portion of the progress bar. Defaults to a semi-transparent blue. - **handleColor** (Color) - Optional - The color for the handle (scrubber) of the progress bar. Defaults to a light gray. - **backgroundColor** (Color) - Optional - The color for the background of the progress bar. Defaults to a semi-transparent gray. ### Example ```dart ChewieProgressColors( playedColor: Colors.red, bufferedColor: Colors.blue, handleColor: Colors.grey, backgroundColor: Colors.grey.withOpacity(0.5), ) ``` ``` -------------------------------- ### allowFullScreen Property Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController/allowFullScreen.html Defines if the fullscreen control should be shown. ```APIDOC ## allowFullScreen Property ### Description Defines if the fullscreen control should be shown. ### Type bool ### Final True ### Implementation ```dart final bool allowFullScreen; ``` ``` -------------------------------- ### Looping Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController-class.html Configures the video player to loop the video playback indefinitely. ```APIDOC ## looping ### Description Whether or not the video should loop. ### Type `bool` ``` -------------------------------- ### Chewie Constructor Source: https://pub.dev/documentation/chewie/1.14.0/chewie/Chewie/Chewie.html The Chewie constructor requires a `ChewieController` to be provided. It also accepts an optional `Key`. ```APIDOC ## Chewie Constructor ### Description Initializes a new instance of the Chewie widget. ### Parameters - **key** (Key?) - Optional - A key to identify this widget. - **controller** (ChewieController) - Required - The controller to manage the Chewie player. ### Implementation ```dart const Chewie({super.key, required this.controller}); ``` ``` -------------------------------- ### videoPlayerController Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController-class.html The controller for the video you want to play. ```APIDOC ## videoPlayerController ### Description The controller for the video you want to play. ### Type VideoPlayerController ### Final true ``` -------------------------------- ### MaterialControls Constructor Source: https://pub.dev/documentation/chewie/1.14.0/chewie/MaterialControls-class.html Initializes a new instance of the MaterialControls class. It accepts an optional boolean `showPlayButton` to control the visibility of a play button and a `key` for widget identification. ```APIDOC ## MaterialControls ### Description Initializes a new instance of the MaterialControls class. ### Parameters * **showPlayButton** (bool) - Optional - Defaults to `true`. Controls whether a play button is displayed. * **key** (Key?) - Optional - Used to identify the widget in the widget tree. ``` -------------------------------- ### Show Controls Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController-class.html A boolean flag to determine whether the video player controls should be displayed at all. ```APIDOC ## showControls ### Description Whether or not to show the controls at all. ### Type `bool` ``` -------------------------------- ### CupertinoControls Constructor Implementation Source: https://pub.dev/documentation/chewie/1.14.0/chewie/CupertinoControls/CupertinoControls.html This is the implementation of the CupertinoControls constructor. It requires backgroundColor and iconColor, and optionally accepts showPlayButton and a Key. ```dart const CupertinoControls({ required this.backgroundColor, required this.iconColor, this.showPlayButton = true, super.key, }); ``` -------------------------------- ### MaterialVideoProgressBar Implementation Source: https://pub.dev/documentation/chewie/1.14.0/chewie/MaterialVideoProgressBar/MaterialVideoProgressBar.html Provides the Dart code for the MaterialVideoProgressBar constructor, initializing its properties and handling default color values. ```dart MaterialVideoProgressBar( this.controller, { this.height = kToolbarHeight, this.barHeight = 10, this.handleHeight = 6, ChewieProgressColors? colors, this.onDragEnd, this.onDragStart, this.onDragUpdate, super.key, this.draggableProgressBar = true, }) : colors = colors ?? ChewieProgressColors(); ``` -------------------------------- ### Is Full Screen Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController-class.html Indicates whether the player is currently in fullscreen mode. ```APIDOC ## isFullScreen ### Description Indicates if the player is currently in fullscreen mode. ### Type `bool` (getter only) ``` -------------------------------- ### Buffering Builder Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController-class.html Provides a custom widget to display while the video is buffering. ```APIDOC ## bufferingBuilder ### Description When the video is buffering, you can build a custom widget. ### Type `WidgetBuilder?` ``` -------------------------------- ### isFullScreen Property Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController/isFullScreen.html A boolean getter that returns the current full-screen status of the Chewie player. ```APIDOC ## isFullScreen Property ### Description Returns `true` if the Chewie player is currently in full-screen mode, `false` otherwise. ### Getter `isFullScreen` ### Return Type `bool` ### Implementation ```dart bool get isFullScreen => _isFullScreen; ``` ``` -------------------------------- ### Define Placeholder Widget Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController/placeholder.html Declare the placeholder widget which is displayed before the video is initialized or played. ```dart final Widget? placeholder; ``` -------------------------------- ### Is Live Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController-class.html Determines if the video player controls should be displayed for live stream content. ```APIDOC ## isLive ### Description Defines if the controls should be shown for live stream video. ### Type `bool` ``` -------------------------------- ### Define systemOverlaysAfterFullScreen Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController/systemOverlaysAfterFullScreen.html This snippet shows the declaration of the systemOverlaysAfterFullScreen property, which is a list of SystemUiOverlay objects. ```dart final List systemOverlaysAfterFullScreen; ``` -------------------------------- ### Declare startAt Property Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController/startAt.html Declare the startAt property as an optional Duration. This property is used to set the initial playback time for the video. ```dart final Duration? startAt; ``` -------------------------------- ### useRootNavigator Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieController-class.html Defines if push/pop navigations use the rootNavigator. ```APIDOC ## useRootNavigator ### Description Defines if push/pop navigations use the rootNavigator. ### Type bool ### Final true ``` -------------------------------- ### ChewieProgressColors Constructor Source: https://pub.dev/documentation/chewie/1.14.0/chewie/ChewieProgressColors/ChewieProgressColors.html The ChewieProgressColors constructor allows you to define the colors for different parts of the video progress bar, including the played portion, buffered portion, handle, and background. ```APIDOC ## ChewieProgressColors Constructor ### Description Initializes a new instance of the ChewieProgressColors class with customizable colors for the video progress bar. ### Parameters #### Constructor Parameters - **playedColor** (Color) - Optional - The color for the played portion of the progress bar. Defaults to `const Color.fromRGBO(255, 0, 0, 0.7)`. - **bufferedColor** (Color) - Optional - The color for the buffered portion of the progress bar. Defaults to `const Color.fromRGBO(30, 30, 200, 0.2)`. - **handleColor** (Color) - Optional - The color for the progress bar handle. Defaults to `const Color.fromRGBO(200, 200, 200, 1.0)`. - **backgroundColor** (Color) - Optional - The background color of the progress bar. Defaults to `const Color.fromRGBO(200, 200, 200, 0.5)`. ### Implementation Details This constructor initializes `Paint` objects with the provided colors for rendering the progress bar elements. ```