【发布时间】:2021-04-01 03:02:47
【问题描述】:
我有一个表单,里面有几个文本字段和一个水平滚动视图,我可以在其中上传一些图像。
表单的宽度比屏幕小,因此列表视图也会受到影响。我希望这个列表视图溢出他的父母,并且和手机屏幕一样宽。
我该怎么做?我正在尝试使用 OverflowBox,但出现错误。这是我的工作代码:
class HorizontalScrollWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return
Container(
child: Column(
children: [
Container(
child: AutoSizeText(
".....",
maxLines: 1,
style: ....,
),
),
_buildFeaturedCards(5),
],
),
);
}
}
Widget _buildFeaturedCards(int maxLength) {
final cards = <Widget>[];
Widget ScrollableCardsRow;
if (maxLength > 0) {
for (int i = 0; i < maxLength; i++) {
cards.add( SquarePhotoElement() );
}
ScrollableCardsRow = Container(
// TODO: OverflowBox??
child: Column(
children: <Widget>[
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(children: cards),
),
],
),
);
} else {
ScrollableCardsRow = Container();
}
return ScrollableCardsRow;
}
感谢您的帮助
【问题讨论】:
标签: flutter dart flutter-layout flutter-listview