android patch

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-06-04 13:49:44 +08:00
parent 7b01c33657
commit f637771527
6 changed files with 16 additions and 602 deletions

View File

@@ -3,12 +3,7 @@ import 'dart:io' show Platform;
import 'package:PiliPlus/utils/device_utils.dart';
import 'package:flutter/services.dart'
show
SystemChrome,
MethodChannel,
SystemUiOverlay,
DeviceOrientation,
SystemUiMode;
show SystemChrome, MethodChannel, SystemUiOverlay, DeviceOrientation;
bool _isDesktopFullScreen = false;
@@ -74,7 +69,7 @@ Future<void>? hideSystemBar() {
return null;
}
_showSystemBar = false;
return setEnabledSystemUIMode(.immersiveSticky);
return SystemChrome.setEnabledSystemUIMode(.immersiveSticky);
}
//退出全屏显示
@@ -83,35 +78,8 @@ Future<void>? showSystemBar() {
return null;
}
_showSystemBar = true;
return setEnabledSystemUIMode(
return SystemChrome.setEnabledSystemUIMode(
Platform.isAndroid && DeviceUtils.sdkInt < 29 ? .manual : .edgeToEdge,
overlays: SystemUiOverlay.values,
);
}
// TODO: remove
// https://github.com/flutter/flutter/issues/186723
Future<void> setEnabledSystemUIMode(
SystemUiMode mode, {
List<SystemUiOverlay>? overlays,
}) {
if (!Platform.isAndroid) {
return SystemChrome.setEnabledSystemUIMode(mode, overlays: overlays);
}
if (mode != SystemUiMode.manual) {
return const MethodChannel('PiliPlus').invokeMethod(
'SystemChrome.setEnabledSystemUIMode',
{'arguments': mode.toString()},
);
} else {
assert(mode == SystemUiMode.manual && overlays != null);
return const MethodChannel('PiliPlus').invokeMethod(
'SystemChrome.setEnabledSystemUIOverlays',
{'arguments': _stringify(overlays!)},
);
}
}
List<String> _stringify(List<dynamic> list) => <String>[
for (final dynamic item in list) item.toString(),
];