如何设置Flutter Text行间距?

and*_*rew 6 flutter

我曾经使用Android开发应用程序,现在使用Flutter,但我想查找与'android:includeFontPadding'和'android:lineSpacingExtra'相同的Text属性?

Sid*_*kar 20

看起来您在寻找类的height属性TextStyle。这是一个例子:

Text(
  "Some lines of text",
  style: TextStyle(
    fontSize: 14.0,
    height: 1.5 //You can set your custom height here
  )
)
Run Code Online (Sandbox Code Playgroud)

  • 它有效,但我发现第一行顶部也有空间,并且颤振现在具有与“android:includeFontPadding”相同的属性 (3认同)

小智 6

尝试以下代码:

Text(
  "Your text",
  style: TextStyle(height: 1.5),
),
Run Code Online (Sandbox Code Playgroud)


Ter*_*rry 5

您可以设置2个属性

Text("Hello World", style: TextStyle(
  height: 1.2 // the height between text, default is 1.0
  letterSpacing: 1.0 // the white space between letter, default is 0.0
));
Run Code Online (Sandbox Code Playgroud)

  • 现在(Flutter 1.9.1),“height: null”和“height: 1.0”不是相同的行为。默认为“height: null”而不是“height: 1.0”。 (3认同)