簡體   English   中英

Flutter:文本:將新行與上一行對齊(縮進)

[英]Flutter: Text: Align new line with previous line (indentation)

基本上我的文字發生的事情是這樣的:

在此處輸入圖片說明

這段文字是使用以下代碼制作的:

child: Text(
            "1)    Persons with burns, skin infections\n2)    Primary or secondary immunodeficiencies (HIV)\n3)    Previous tuberculosis infection\n4)    Untreated active tuberculosis\n5)    History of close contact with tuberculosis patient\n6)    Immunosupressed individuals (i.e. HIV infected, leukemia, lymphoma, malignancy)\n7)    People receiving immunosuppressive medications (including high-dose steroids\n8)    Pregnancy",
          ),

我希望 6) 和 7) 中的第二行與文本的開頭對齊,而不是與數字對齊。 有沒有辦法在顫振中做到這一點?

我不想添加額外的空間,因為它可能會隨着不同的移動屏幕而改變。 還有其他情況涉及超過 2 行。 謝謝你的回答!

我假設你已經創建了這樣的東西:

return new ListView(
  shrinkWrap: true,
  children: <Widget>[
   const Text('1) I\'m dedicating every day to you'),
   const Text('2) Domestic life was never quite my style'),
   const Text('3) When you smile, you knock me out, I fall apart'),
   const Text('4) And I thought I was so smart')
  ]
);

您可以使用Row Widget來實現您想要的結果:

return new ListView(shrinkWrap: true, children: <Widget>[
  new Row(children: <Widget>[
    Text('1) '),
    Expanded(child: Text('I\'m dedicating every day to you'))
  ], crossAxisAlignment: CrossAxisAlignment.start),
  new Row(children: <Widget>[
    Text('2) '),
    Expanded(child: Text('Domestic life was never quite my style'))
  ], crossAxisAlignment: CrossAxisAlignment.start),
  new Row(children: <Widget>[
    Text('3) '),
    Expanded(child: Text('When you smile, you knock me out, I fall apart blablabla'))
  ], crossAxisAlignment: CrossAxisAlignment.start),
  new Row(children: <Widget>[
    Text('4) '),
    Expanded(child: Text('And I thought I was so smart')),
  ], crossAxisAlignment: CrossAxisAlignment.start)
]);

當然,這有點難看,但我希望它能為您指明正確的方向。

截屏

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM