Flutter 如何利用未来
我的部分代码如下:Flutter 如何利用未来,flutter,flutter-layout,Flutter,Flutter Layout,我的部分代码如下: Expanded( flex: 13, child: Container( padding: EdgeInsets.all(2), color: Colors.black12, child: FutureBuilder( future: getCompromissos(), builder: (context, snapshot
Expanded(
flex: 13,
child: Container(
padding: EdgeInsets.all(2),
color: Colors.black12,
child: FutureBuilder(
future: getCompromissos(),
builder: (context, snapshot) {
if (compromissosFiltrados != null && compromissosFiltrados.compromissos.length > 0) {
return ListView.builder(
controller: ScrollController(),
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemCount: compromissosFiltrados.compromissos.length,
itemBuilder: (context, index) {
return CompromissoCard(
indice: index,
title: compromissosFiltrados.compromissos[index].nome,
icon: new Icon(icons[0], size: 24.0, color: Colors.green));
},
);
} else {
return Container();
}
},
),
),
),
有时getRecommissionSos()
不返回任何项目,我的应用程序中有一个空白。
我想在没有任何东西可展示的情况下占据所有空间,如下所示:
在下半部分,Expanded(flex:0正在工作,因为该小部件的内容不是来自web
但是在这个小部件中,如果我使用flex:0
,但没有项目,这没关系,但是如果有项目,我会出现如下错误:
RenderBox未布局:RenderPaintBoundary#6c79b
relayoutBoundary=up6-PAINT
“package:flatter/src/rendering/box.dart”:失败的断言:第1694行
位置12:“hasSize”
如果您需要折衷卡的该部分
return new Container(
color: Colors.white12,
child: new Card(
child: Container(
color: Colors.white30,
padding: new EdgeInsets.only(left: 5, top: 5, bottom: 5, right: 10),
child: new Row(children: <Widget>[
Column(children: <Widget>[
SizedBox(height: 15),
Column(children: <Widget>[new Image.asset("assets/images/meeting.png")])
]),
Column(children: <Widget>[
Row(
children: <Widget>[
Column(children: <Widget>[
SizedBox(
height: 15,
),
Text("13:00 - 14:00", style: TextStyle(color: Colors.black38, fontSize: 16)),
SizedBox(
height: 5,
),
Text(this.title, style: TextStyle(color: Colors.black, fontSize: 16, fontWeight: FontWeight.w300))
]),
],
),
])
]),
),
));
返回新容器(
颜色:颜色。白色12,
孩子:新卡(
子:容器(
颜色:Colors.white30,
填充:新边设置。仅限(左:5,上:5,下:5,右:10),
子项:新行(子项:[
栏(儿童:[
尺寸箱(高度:15),
列(子项:[new Image.asset(“assets/images/meeting.png”)])
]),
栏(儿童:[
划船(
儿童:[
栏(儿童:[
大小盒子(
身高:15,
),
文本(“13:00-14:00”,样式:TextStyle(颜色:Colors.black38,fontSize:16)),
大小盒子(
身高:5,,
),
文本(this.title,style:TextStyle(颜色:Colors.black,fontSize:16,fontwweight:fontwweight.w300))
]),
],
),
])
]),
),
));
我不知道该怎么做
有人能帮我吗?先谢谢你