我試圖在一行中顯示復選框的文本,但它分成了第二行。這是代碼:
我創建了一個自定義的 ExpansionListTile:
customExpansionTile(
context,
"Visting Time",
true,
Icon(Icons.timer_rounded, color: HexColor("#5344ed")), //leading
<Widget>[
Container(
child: Row(
children: [
Expanded(
child: SizedBox(
height: MediaQuery.of(context).size.height * 0.45,
child: ListTile(
//font change
subtitle: ListView.builder(
itemCount: checkBoxListTileModelForVisting.length,
itemBuilder: (BuildContext context, int index) {
return new Container(
padding: new EdgeInsets.all(0.0),
child: Column(
children: <Widget>[
new CheckboxListTile(
controlAffinity:
ListTileControlAffinity.leading,
activeColor: HexColor("#5344ed"),
dense: true,
//font change
title: new Text(
checkBoxListTileModelForVisting[index].title,
style: GoogleFonts.montserrat(
fontSize: 12,
),
),
value: checkBoxListTileModelForVisting[index]
.isCheck,
secondary: Container(
padding:EdgeInsets.only(left: 100),
height: MediaQuery.of(context).size.width *0.9,
width: MediaQuery.of(context).size.height *0.2,
child:
checkBoxListTileModelForVisting[index].isCheck ==true?
IconButton(
tooltip:"Pick Time",
onPressed: () {
_VisitingTimeDialogue(
checkBoxListTileModelForVisting[index]
.title);
},
icon: Icon(Icons.add)
)
: null),
onChanged: (bool? val) {
itemChangeforVisiting(val!, index);
}),
星期三顯示不正確,請告訴我哪里做錯了。

uj5u.com熱心網友回復:
替換width為height
height: MediaQuery.of(context).size.width *0.9,
width: MediaQuery.of(context).size.height *0.2,
喜歡
height: MediaQuery.of(context).size.height *0.9,
width: MediaQuery.of(context).size.width *0.2,
我認為你secondary占用了額外的空間,使用擴展而不是寬度是有意義的
并添加到Text overflow: TextOverflow.ellipsis和maxLines: 1
喜歡
Text('your text', overflow: TextOverflow.ellipsis, maxLines: 1)
如果它不能幫助您嘗試使用 autoSizeText 包
uj5u.com熱心網友回復:
checkboxlisttile 包裝到容器并給出最大寬度
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/317306.html
