保持屏幕 唤醒 + 隐藏 系统状态栏

This commit is contained in:
shikong 2023-11-26 20:04:42 +08:00
parent 174f3e9341
commit b08fa90fc1

View File

@ -28,7 +28,7 @@ class _CustomVideoPlayerState extends State<CustomVideoPlayer> {
void initState() { void initState() {
super.initState(); super.initState();
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [SystemUiOverlay.bottom]); SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky, overlays: [SystemUiOverlay.bottom]);
SystemChrome.setPreferredOrientations( SystemChrome.setPreferredOrientations(
[DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]); [DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]);
Wakelock.enable(); Wakelock.enable();
@ -178,7 +178,7 @@ class _CustomVideoPlayerState extends State<CustomVideoPlayer> {
@override @override
void dispose() { void dispose() {
Wakelock.disable(); Wakelock.disable();
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [SystemUiOverlay.top]); SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky, overlays: [SystemUiOverlay.top]);
SystemChrome.setPreferredOrientations([]); SystemChrome.setPreferredOrientations([]);
player?.stop().then((value) => player?.dispose()); player?.stop().then((value) => player?.dispose());
_controller?.dispose(); _controller?.dispose();