[英]How to give to a Flutter container the Height equivalent to the child and children inside himself
[英]How to give to a Flutter container the Height equivalent to the listview child inside himself
當我沒有給容器一個高度時我有一個錯誤,它給我這個錯誤:
========渲染庫捕獲異常===================================== ================ 在 paint() 期間拋出以下 _CastError:Null 檢查運算符用於 null 值
所以為什么我 gihe hime 高度:200 但它的 static 高度我想給容器一個 listview 的大小在他里面。
容器代碼:
Container(
// height:200,
alignment: Alignment.topLeft,
decoration: const BoxDecoration(
border: Border(
// top: BorderSide(color: Colors.black12),
bottom: BorderSide(color: Colors.black12),
)),
padding: const EdgeInsets.fromLTRB(10, 5, 0, 20),
child: Column(
children: <Widget>[
Container(width: 22, color: colors),
Expanded(
child: ListView.builder(
padding: const EdgeInsets.symmetric(vertical: 8.0),
itemCount: reposReplay?.length,
itemBuilder: (context, index) {
return Column(
children: <Widget>[
ListTile(
title: Column(children: [
Padding(
padding:
const EdgeInsets.fromLTRB(0, 0, 0, 10),
child: Row(
children: [
Expanded(
child: Text("${reposReplay?[index].by}",
textAlign: TextAlign.start,
style: const TextStyle(
fontSize: 14,
color: Colors.deepOrangeAccent,
fontWeight: FontWeight.bold)),
),
Expanded(
child: Text(time,
textAlign: TextAlign.end,
style: const TextStyle(
fontSize: 14,
color: Colors.deepOrangeAccent,
fontWeight: FontWeight.bold)),
),
],
),
),
]),
subtitle: Text("${reposReplay?[index].text!.replaceAll("'", "'").replaceAll(">", ">").replaceAll(""", "\"").replaceAll("/", "/").replaceAll("<p>", "\n").replaceAll(">."", ">.").replaceAll(exp, "")}",
textAlign: TextAlign.justify,
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.normal, color: Colors.black)),
),
const Divider(
height: 2.0,
),
],
);
}),
)
],
)
),
在 listview.builder 中使用以下內容:
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.