Flutter - 水平滚动旁边的固定按钮
Flutter - Fixed button next to horizontal scroll
我有一个带按钮的对话框,我想在按钮旁边添加一个水平滚动条,所以这样按钮固定在左边,滚动条在右边。我尝试使用行,但出现以下错误:
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),
],
),
)
],
),
),
您可以在 ListView
上使用 shrinkWrap: true,
SizedBox(
height: 80,
child: ListView(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
children: <Widget>[....],
),
您可以查看更多关于
也给 SizeBox()
width
并使用 shrikWrap
和你的 Listview
。因为卷轴是 Horizontal
它要求你一个固定的 widht
.
我有一个带按钮的对话框,我想在按钮旁边添加一个水平滚动条,所以这样按钮固定在左边,滚动条在右边。我尝试使用行,但出现以下错误:
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),
],
),
)
],
),
),
您可以在 ListView
shrinkWrap: true,
SizedBox(
height: 80,
child: ListView(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
children: <Widget>[....],
),
您可以查看更多关于
也给 SizeBox()
width
并使用 shrikWrap
和你的 Listview
。因为卷轴是 Horizontal
它要求你一个固定的 widht
.