[英]Adjust new line spacing in Flutter Text Widget
所以,目標很簡單,將一堆文本包裝在一個容器中。 為此,我遵循了這個Flutter-wrapping text ,但創建的新行與前一行之間有太多空間。
我的帶有 Text() 的 Container() 代碼:
description == ""
? SizedBox.shrink()
: Container(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
//width: MediaQuery.of(context).size.width * 0.8,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
new Text(
description,
textAlign: TextAlign.left,
style: TextStyle(fontSize: 18),
),
],
),
)
小提示:如果對 Parent 小部件給出了任何描述,我只使用 SizeBox.shrink() 作為“空小部件”。
當前情況如何,空間太大:
應該如何:
我知道 1º 圖像更大,但這不是行距更大的原因 😄
正如從 這里提到的。 您可以通過更改樣式內的height
屬性來調整行距。 1.0對我來說似乎不錯,但您可以嘗試將其設置為0.8 , 0.7 。
Container(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
//width: MediaQuery.of(context).size.width * 0.8,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
new Text(
'You have pushed the button this many times: You have pushed the button this many times: You have pushed the button this many times: You have pushed the button this many times: You have pushed the button this many times: You have pushed the button this many times: You have pushed the button this many times:',
textAlign: TextAlign.left,
style: TextStyle(fontSize: 18, height: 1.0 ),
),
],
),),
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.