末端测试中
This commit is contained in:
@@ -283,11 +283,14 @@ class _BatteryHealthPageState extends State<BatteryHealthPage>
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
// 触发关闭
|
||||
Navigator.pop(context);
|
||||
// 保存 context 引用
|
||||
final ctx = context;
|
||||
|
||||
// 延迟确保动画完成
|
||||
await Future.delayed(const Duration(milliseconds: 150));
|
||||
// 尝试关闭对话框
|
||||
Navigator.of(ctx, rootNavigator: true).pop();
|
||||
|
||||
// 等待动画完成
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
|
||||
final result = await _safService.requestPermission();
|
||||
|
||||
@@ -297,6 +300,14 @@ class _BatteryHealthPageState extends State<BatteryHealthPage>
|
||||
setState(() {
|
||||
_safState = SafPermissionState.authorized;
|
||||
});
|
||||
|
||||
// 🟢 兜底:在下一帧再次尝试关闭
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
Navigator.of(ctx, rootNavigator: true).pop();
|
||||
}
|
||||
});
|
||||
|
||||
readBatteryCapacity();
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
|
||||
Reference in New Issue
Block a user