这是支架的主体,我不太了解为什么我会收到此错误?我在高度和宽度上增加了限制。仍然没有得到错误。对我来说,身体的顺序似乎合乎逻辑吗?
body:Center(child:SingleChildScrollView
(child: Column(
children:_list1
.map((element)=>
Container(
margin: EdgeInsets.all(9.0),
constraints: new BoxConstraints.expand(height: 300.0),
decoration: new BoxDecoration(
border: new Border.all(color: Colors.blueAccent),
borderRadius: BorderRadius.horizontal( left:Radius.circular(30.0) ,right:Radius.circular(30.0) ),
image: new DecorationImage(
image: new AssetImage('assets/food1.jpg'),
fit: BoxFit.cover,),),
padding: EdgeInsets.only(bottom: 20.0),
child: Stack(
children:<Widget>[
Positioned(left: 0.0,bottom: 30.0,child: Text(element.name, style: new TextStyle(fontWeight: FontWeight.bold,fontSize: 20.0,)),),
Positioned(left: 0.0,bottom: 0.0,child: Text(element.dis,style: new TextStyle(fontWeight: FontWeight.bold,fontSize: 20.0,)),),
Positioned(right: 0.0,top:0.0,child:Icon(Icons.star)),
Positioned(right: 200.0,top:0.0,child:Icon(Icons.check)),
]
),
),
).toList()
)
) )
);
答案 0 :(得分:1)
您可以使用ListView代替Center
,SingleChildScrollView
和Column
。
body: ListView(
children: _list1
.map(
(element) => Container(
margin: EdgeInsets.all(9.0),
constraints: new BoxConstraints.expand(height: 300.0),
decoration: new BoxDecoration(
border: new Border.all(color: Colors.blueAccent),
borderRadius: BorderRadius.horizontal(
left: Radius.circular(30.0),
right: Radius.circular(30.0),
),
image: new DecorationImage(
image: new NetworkImage(
'https://images.pexels.com/photos/5317/food-salad-restaurant-person.jpg?auto=compress&cs=tinysrgb&h=350'),
fit: BoxFit.cover,
),
),
padding: EdgeInsets.only(bottom: 20.0),
child: Stack(
children: <Widget>[
Positioned(
left: 0.0,
bottom: 30.0,
child: Text(
element.name,
style: new TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20.0,
),
),
),
Positioned(
left: 0.0,
bottom: 0.0,
child: Text(
element.dis,
style: new TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20.0,
),
),
),
Positioned(
right: 0.0,
top: 0.0,
child: Icon(Icons.star),
),
Positioned(
right: 200.0,
top: 0.0,
child: Icon(Icons.check),
),
],
),
),
)
.toList(),
),
在您的代码中Center
似乎没用。