gpt4 book ai didi

flutter - 当我在Stack(Positioned)中使用ListView时发生问题

转载 作者:行者123 更新时间:2023-12-03 03:50:00 24 4
gpt4 key购买 nike

我想在屏幕上显示三件事,一个显示日期的时间表,一个包含几个ListViewContainer,并在屏幕底部显示一个导航栏。之所以将它们放在Stack中,是因为ListView比屏幕尺寸长,我不想让它阻塞导航栏。我的问题是关于ListView的内容根本不显示,因此底部导航栏为空白。我试图用ListView替换Column,它可以工作,但不是我想要的。和错误=

RenderBox was not laid out: RenderRepaintBoundary#40da3relayoutBoundary=up2 NEEDS-PAINT'package:flutter/src/rendering/box.dart': Failed assertion: line 1694pos 12: 'hasSize'

body: Stack(
children: <Widget>[
Positioned(
top: 0,
child: timeTable(),
),
Positioned(
top: 114.0,
height: 200,
child: ListView(
children: <Widget>[
Container(height: 100,),
Container(height: 100,),
],
)
),
Positioned(
bottom: 0,
child: NavigationBar(),
),
],
),
下面是关于timeTable()类
    Widget timeTable() {
return Container(
height: 98.0,
width: 540.0,
margin: EdgeInsets.only(left: 114.0, right: 114.0),
child: Column(
children: <Widget>[
SizedBox(height: 24.0,),
Container(
height: 24.0,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
child: Text('日付', style: StatisticTextStyle.date, ),
),
stuckButtons(),
],
),
),
Container(
padding: EdgeInsets.only(bottom: 0),
height: 44,
child: Container(
alignment: Alignment.bottomRight,
padding: EdgeInsets.only(top: 0),
child: RichText(
text: TextSpan(
children: [
TextSpan(
text: "2020年10月15日 ",
style: StatisticTextStyle.mainText,
),
WidgetSpan(
// make the icon higher so that alignment with the text.
child: Container(
padding: EdgeInsets.only(bottom: 2),
child: MyIcon.calendarIcon,
)
),
],
),
),
),
),
],
),
);
}

最佳答案

我已经解决了问题。
我选择Stack的原因是关于自定义底部导航栏,因为小部件属于主体。实际上,我们可以在Scaffold中使用bottomNavigationBar
因此剩下的问题是如何维护窗口小部件和ListView中的Column以显示在屏幕上。
新的错误信息=

The following assertion was thrown during performResize(): Verticalviewport was given unbounded height.it's not difficult to find we should give the ListView a height. Put the ListView into a container and set the height of the container then it will be Okay.

关于flutter - 当我在Stack(Positioned)中使用ListView时发生问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63787731/

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