fix(profile): 修复伞下树图未居中问题

使用 LayoutBuilder 获取实际容器宽度而不是屏幕宽度

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-15 04:25:19 -08:00
parent 6dd7e64a95
commit 4d6ce3ce08
1 changed files with 19 additions and 14 deletions

View File

@ -81,23 +81,28 @@ class _TeamTreeWidgetState extends State<TeamTreeWidget> {
@override
Widget build(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width;
return LayoutBuilder(
builder: (context, constraints) {
// 使
final containerWidth = constraints.maxWidth;
return SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(
minWidth: screenWidth,
),
child: Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: _buildTreeLevel([widget.rootNode], 0),
return SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(
minWidth: containerWidth,
),
child: Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: _buildTreeLevel([widget.rootNode], 0),
),
),
),
),
),
),
);
},
);
}