我有一个不知道如何解决的问题: 在我的应用程序中,有一个Map从Firebase数据库检索数据,到目前为止一切正常。 现在,我要遍历地图,以在可滚动页面的容器内打印键和值。
我编写了这段代码,它可以工作,但是此解决方案使容器可滚动而不是页面:(
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: new Color(0xFFF8F8FF),
appBar: new AppBar(
backgroundColor: Colors.transparent,
elevation: 0.0,
iconTheme: new IconThemeData(color: Colors.blueAccent),
),
body: new Column(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
slider,
carDescrContent
],
));
final carDescrContent = new Expanded(
child: new Container(
constraints: BoxConstraints.expand(),
decoration: new BoxDecoration(
color: Colors.white,
shape: BoxShape.rectangle,
borderRadius: new BorderRadius.circular(8.0),
boxShadow: <BoxShadow>[
new BoxShadow(
color: Colors.black12,
blurRadius: 5.0,
offset: new Offset(0.0, 6.0))
]),
margin:
const EdgeInsets.symmetric(vertical: 10.0, horizontal: 25.0),
child: new ListView.builder(
itemCount: map.length,
itemBuilder: (BuildContext context, int index) {
String key = map.keys.elementAt(index);
return new Container(
margin: new EdgeInsets.symmetric(horizontal: 16.0),
child:
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[new Text("${key}"), new Text(map[key])],
));
})));
谢谢