Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to pass OverlayState for showing the fullscreen player #282

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions lib/src/flick_video_player.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:flick_video_player/src/utils/web_key_bindings.dart';
import 'package:universal_html/html.dart';
import 'package:flick_video_player/flick_video_player.dart';
import 'package:flick_video_player/src/utils/web_key_bindings.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:universal_html/html.dart';
import 'package:wakelock_plus/wakelock_plus.dart';

class FlickVideoPlayer extends StatefulWidget {
Expand All @@ -27,6 +27,7 @@ class FlickVideoPlayer extends StatefulWidget {
this.wakelockEnabled = true,
this.wakelockEnabledFullscreen = true,
this.webKeyDownHandler = flickDefaultWebKeyDownHandler,
this.overlay,
}) : super(key: key);

final FlickManager flickManager;
Expand Down Expand Up @@ -64,6 +65,11 @@ class FlickVideoPlayer extends StatefulWidget {
/// Callback called on keyDown for web, used for keyboard shortcuts.
final Function(KeyboardEvent, FlickManager) webKeyDownHandler;

/// The [OverlayState] that is used to show the fullscreen player on.
///
/// Defaults to the overlay from `Overlay.of(context)`.
final OverlayState? overlay;

@override
_FlickVideoPlayerState createState() => _FlickVideoPlayerState();
}
Expand Down Expand Up @@ -156,7 +162,10 @@ class _FlickVideoPlayerState extends State<FlickVideoPlayer>
);
});

Overlay.of(context).insert(_overlayEntry!);
if (widget.overlay != null)
widget.overlay!.insert(_overlayEntry!);
else
Overlay.of(context).insert(_overlayEntry!);
}
}

Expand Down