[英]Nested ListView not visibile - Flutter
我有兩個列表視圖。 一個是視圖中所有小部件的包裝器,第二個是它的子級。 這是代碼:
ListView(
scrollDirection: Axis.vertical,
physics: AlwaysScrollableScrollPhysics(),
children: [
Container(
................
),
Container(
................
),
ListView.builder(
itemBuilder: (context, index) {
return Expanded(child: Column(children: [
Divider(
color: Colors.black12,
height: 20,
thickness: 1,
indent: 20,
endIndent: 0,
),
Row(children: [
Image.network(
"http://openweathermap.org/img/wn/10d@2x.png"),
Text(Utils.days[index + 1],
style: GoogleFonts.roboto(
fontSize: 16, color: Colors.white))
]),
]));
},
itemCount: 5,
scrollDirection: Axis.vertical,
)
]);
這兩個容器是可見的。 我看不到第二個列表視圖中的項目。 控制台沒有任何錯誤。 我不知道為什么會這樣。
我希望這段代碼對你有用。
return Scaffold(
body: Container(
child: SingleChildScrollView(
child: Column(mainAxisSize: MainAxisSize.min,
// scrollDirection: Axis.vertical,
// physics: AlwaysScrollableScrollPhysics(),
children: [
Container(
child: Text("one"),
),
Container(
child: Text("two"),
),
Container(
height: MediaQuery.of(context).size.height / 2,
child: ListView.builder(
itemBuilder: (context, index) {
return Column(children: [
Divider(
color: Colors.black12,
height: 20,
thickness: 1,
indent: 20,
endIndent: 0,
),
Row(children: [
Image.network(
"http://openweathermap.org/img/wn/10d@2x.png"),
Text(index.toString(),
style: GoogleFonts.roboto(
fontSize: 16, color: Colors.white))
]),
]);
},
itemCount: 5,
scrollDirection: Axis.vertical,
),
)
]),
)),
);
我通過將 shrinkWrap: true 和 Physics: NeverScrollableScrollPhysics() 添加到嵌套的 ListView 來修復它
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.