Skip to content

Commit cdc6b82

Browse files
committed
fix: 规避 Flutter Windows AXTree 报错 (flutter/flutter#182444)
- NavigationView 外包裹 ExcludeSemantics 阻止有问题的 accessibility tree 更新 - 根本原因: Flutter 引擎在节点重新父化时 AXTree 更新失败 (P2 已知 bug)
1 parent 1652ac7 commit cdc6b82

1 file changed

Lines changed: 47 additions & 42 deletions

File tree

‎lib/app.dart‎

Lines changed: 47 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -32,48 +32,53 @@ class _AppShellState extends State<AppShell> {
3232

3333
@override
3434
Widget build(BuildContext context) {
35-
return NavigationView(
36-
transitionBuilder: (child, animation) {
37-
return EntrancePageTransition(
38-
animation: animation,
39-
child: child,
40-
);
41-
},
42-
pane: NavigationPane(
43-
selected: _selectedIndex,
44-
onChanged: (index) => setState(() => _selectedIndex = index),
45-
// 自动响应屏幕宽度切换显示模式,内建 toggle 按钮
46-
displayMode: PaneDisplayMode.auto,
47-
items: [
48-
PaneItem(
49-
icon: const Icon(FluentIcons.home),
50-
title: const Text('主页'),
51-
body: const HomePage(),
52-
),
53-
PaneItem(
54-
icon: const Icon(FluentIcons.education),
55-
title: const Text('教务中心'),
56-
body: const AcademicPage(),
57-
),
58-
PaneItem(
59-
icon: const Icon(FluentIcons.info),
60-
title: const Text('信息中心'),
61-
body: const InfoPage(),
62-
),
63-
PaneItem(
64-
icon: const Icon(FluentIcons.link),
65-
title: const Text('快速跳转'),
66-
body: const QuickLinksPage(),
67-
),
68-
],
69-
// 设置项放在导航栏底部
70-
footerItems: [
71-
PaneItem(
72-
icon: const Icon(FluentIcons.settings),
73-
title: const Text('设置'),
74-
body: SettingsPage(onLock: widget.onLock),
75-
),
76-
],
35+
// ExcludeSemantics 规避 Flutter Windows 引擎 bug:
36+
// AXTree 节点重新父化时报错 "Failed to update ui::AXTree"
37+
// 参见 https://github.com/flutter/flutter/issues/182444
38+
return ExcludeSemantics(
39+
child: NavigationView(
40+
transitionBuilder: (child, animation) {
41+
return EntrancePageTransition(
42+
animation: animation,
43+
child: child,
44+
);
45+
},
46+
pane: NavigationPane(
47+
selected: _selectedIndex,
48+
onChanged: (index) => setState(() => _selectedIndex = index),
49+
// 自动响应屏幕宽度切换显示模式,内建 toggle 按钮
50+
displayMode: PaneDisplayMode.auto,
51+
items: [
52+
PaneItem(
53+
icon: const Icon(FluentIcons.home),
54+
title: const Text('主页'),
55+
body: const HomePage(),
56+
),
57+
PaneItem(
58+
icon: const Icon(FluentIcons.education),
59+
title: const Text('教务中心'),
60+
body: const AcademicPage(),
61+
),
62+
PaneItem(
63+
icon: const Icon(FluentIcons.info),
64+
title: const Text('信息中心'),
65+
body: const InfoPage(),
66+
),
67+
PaneItem(
68+
icon: const Icon(FluentIcons.link),
69+
title: const Text('快速跳转'),
70+
body: const QuickLinksPage(),
71+
),
72+
],
73+
// 设置项放在导航栏底部
74+
footerItems: [
75+
PaneItem(
76+
icon: const Icon(FluentIcons.settings),
77+
title: const Text('设置'),
78+
body: SettingsPage(onLock: widget.onLock),
79+
),
80+
],
81+
),
7782
),
7883
);
7984
}

0 commit comments

Comments
 (0)