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:
parent
6dd7e64a95
commit
4d6ce3ce08
|
|
@ -81,23 +81,28 @@ class _TeamTreeWidgetState extends State<TeamTreeWidget> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final screenWidth = MediaQuery.of(context).size.width;
|
return LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
// 使用实际容器宽度而不是屏幕宽度
|
||||||
|
final containerWidth = constraints.maxWidth;
|
||||||
|
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
minWidth: screenWidth,
|
minWidth: containerWidth,
|
||||||
),
|
),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
child: _buildTreeLevel([widget.rootNode], 0),
|
child: _buildTreeLevel([widget.rootNode], 0),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
),
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue