当我向上滚动时,只有一个容器中的数据正在向上移动,因此我想移动整个容器,因此我有一个容器中包含一些车辆数据的列表视图。我不希望这样的用户界面,整个容器应该向上移动,请帮帮我,另一部分是我使用了收缩包装,如果我的列表只有一个值,它会出现在屏幕中央,并且我不想表现这样。
new SingleChildScrollView(
child: new Container(
padding: EdgeInsets.only(left: 24.0, right: 24.0,top: 25.0,bottom: 25.0),
child: new PhysicalModel(
borderRadius: new BorderRadius.circular(20.0),
color: Colors.white,
shadowColor: Colors.grey,
elevation: 0.0,
shape: BoxShape.rectangle,
child:new ListView(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
children: List.generate(
this._allVehiclesData.length,
(i) => new GestureDetector(
onTap: (){
_id = this._allVehiclesData[i]["vehicle"]["_id"];
Navigator.push(context, new MaterialPageRoute(builder: (context) => new SingleVehicleDashboard(value:_id)));
},
child: new Card(
elevation: 0.0,
child:new Container(
padding: const EdgeInsets.only(top:30.0,left: 30.0,right: 30.0),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
this._allVehiclesData[i]["vehicle"]["registration"] != null?
Text(
this._allVehiclesData[i]["vehicle"]["registration"],
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF454f63),
),
):
Text(
'New Vehicle',
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF454f63),
),
),
new Container(
// padding: EdgeInsets.only(left: 50.0),
child: status(i),
),
],
),
),
Text('',
style: TextStyle(
fontSize: 8.0,
),
),
Container(
child: new Row(
children: <Widget>[
new IconTheme(
data: new IconThemeData(
color: Colors.grey,
),
child: Image.asset('assets/person.png'),
),
new Container(
child: new Text(this._allVehiclesData[i]["driver"]["fullname"],
style: TextStyle(
fontSize: 16.0,
color: Color(0xFF78849e),
) ,
)
),
],
),
),
Container(
child: new Column(
children: <Widget>[
new Text(''),
new Container(
child: new Text('',
style: TextStyle(
fontSize: 5.0,
) ,
)
),
],
),
),
Container(
child:
this._allVehiclesData[i]["temperature"] != "null" && this._allVehiclesData[i]["fuel"] != "null"?
new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
new Row(
children: <Widget>[
new IconTheme(
data: new IconThemeData(
color: Color(0xFF78849e),
size: 20.0,
),
child: Icon(Icons.ac_unit),
),
new Container(
child: new Text((' '+this._allVehiclesData[i]["temperature"].toString()+' C'),
style: TextStyle(
fontSize: 16.0,
color: Color(0xFF78849e),
) ,
)
),
],
),
new Row(
children: <Widget>[
new IconTheme(
data: new IconThemeData(
color: Color(0xFF78849e),
size: 20.0,
),
child: Icon(Icons.local_gas_station),
),
new Container(
child: new Text((this._allVehiclesData[i]["fuel"].toString()),
style: TextStyle(
fontSize: 16.0,
color: Color(0xFF78849e),
) ,
)
),
],
),
],
):
this._allVehiclesData[i]["temperature"] !="null"?
new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
new Row(
children: <Widget>[
new IconTheme(
data: new IconThemeData(
color: Color(0xFF78849e),
),
child: Icon(Icons.ac_unit),
),
new Container(
child: new Text((this._allVehiclesData[i]["temperature"].toString()+' C'),
style: TextStyle(
fontSize: 16.0,
color: Color(0xFF78849e),
) ,
)
),
],
),
],
):
this._allVehiclesData[i]["fuel"] !="null"?
new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Row(
children: <Widget>[
new IconTheme(
data: new IconThemeData(
color: Color(0xFF78849e),
),
child: Icon(Icons.local_gas_station),
),
new Container(
child: new Text((this._allVehiclesData[i]["fuel"].toString()),
style: TextStyle(
fontSize: 16.0,
color: Color(0xFF78849e),
) ,
)
),
],
),
],
):new Text(''),
),
new Text('',style: TextStyle(fontSize: 7.0)),
new Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new IconTheme(
data: new IconThemeData(
color: Color(0xFF78849e),
),
child: Icon(Icons.location_on),
),
Expanded(
child: new Text((this._allVehiclesData[i]["address"] == null ||
this._allVehiclesData[i]["address"] == 'Not determined') ?
"No data available" : this._allVehiclesData[i]["address"]["LongLabel"],
style: TextStyle(
letterSpacing: 0.5,
height: 1.0,
fontSize: 16.0,
color: Color(0xFF78849e),
),
),
),
],
),
Text(''),
Divider(
height: 3.0,
color: Color(0xFFf4f4f6),
),
],
),
),
],
),
),
),
),
),
)
),
)
)
答案 0 :(得分:1)
在SingleChildScrollView
和ListView中定义包装容器-
shrinkWrap: true,
physics: NeverScrollableScrollPhysics()
-像这样更新您的代码
body: SingleChildScrollView(
child: new Container(
padding: EdgeInsets.only(left: 24.0, right: 24.0, top: 25.0),
child: new PhysicalModel(
borderRadius: new BorderRadius.only(
topLeft: Radius.circular(20.0), topRight: Radius.circular(20.0)),
color: Colors.white,
shadowColor: Colors.grey,
elevation: 1.0,
shape: BoxShape.rectangle,
child: new ListView(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
.....