gpt4 book ai didi

Flutter - 水平滚动旁边的固定按钮

转载 作者:行者123 更新时间:2023-12-05 03:29:40 26 4
gpt4 key购买 nike

我有一个带按钮的对话框,我想在按钮旁边添加一个水平滚动条,所以这样按钮固定在左边,滚动条在右边。我尝试使用 Row 但出现以下错误:

The following assertion was thrown during performResize():Horizontal viewport was given unbounded width....The following assertion was thrown during performLayout():RenderBox was not laid out: RenderViewport#48cb5 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE'package:flutter/src/rendering/box.dart':Failed assertion: line 1982 pos 12: 'hasSize'...

我为此使用的具体代码如下:

      SizedBox(
height: 80,
child: Row(
children: <Widget>[
AddUsersButton(newTaskCubit: newTaskCubit),
SizedBox(
height: 80,
child: ListView(
scrollDirection: Axis.horizontal,
children: <Widget>[
UserExample(newTaskCubit: newTaskCubit),
UserExample(newTaskCubit: newTaskCubit),
UserExample(newTaskCubit: newTaskCubit),
UserExample(newTaskCubit: newTaskCubit),
],
),
)
],
),
),

最佳答案

也给 SizeBox() width 并在 Listview 中使用 shr​​ikWrap 。因为滚动是 Horizo​​ntal 它需要一个固定的 widht

关于Flutter - 水平滚动旁边的固定按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70991426/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com