末端测试中
This commit is contained in:
@@ -283,11 +283,14 @@ class _BatteryHealthPageState extends State<BatteryHealthPage>
|
|||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
// 触发关闭
|
// 保存 context 引用
|
||||||
Navigator.pop(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();
|
final result = await _safService.requestPermission();
|
||||||
|
|
||||||
@@ -297,6 +300,14 @@ class _BatteryHealthPageState extends State<BatteryHealthPage>
|
|||||||
setState(() {
|
setState(() {
|
||||||
_safState = SafPermissionState.authorized;
|
_safState = SafPermissionState.authorized;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 🟢 兜底:在下一帧再次尝试关闭
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (mounted) {
|
||||||
|
Navigator.of(ctx, rootNavigator: true).pop();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
readBatteryCapacity();
|
readBatteryCapacity();
|
||||||
} else {
|
} else {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
|||||||
Reference in New Issue
Block a user