如何在颤振文本小部件内下划线文本?

我似乎无法在TextStyle的fontStyle属性内找到下划线


当前回答

例如

Text(
  "Terms and Condition",
  style: TextStyle(
    decoration:
        TextDecoration.underline,
    height: 1.5,
    fontSize: 15,
    fontWeight: FontWeight.bold,
    fontFamily: 'Roboto-Regular',
  ),
),

其他回答

下面是一个简单的代码

Text(
  'Welcome to Flutter',
  style: TextStyle(decoration:TextDecoration.underline,),
),

您可以使用decorationStyle来定制它

Text(
  'Welcome to Flutter',
  style: TextStyle(
  fontSize: 24,
  decoration: TextDecoration.underline,
  decorationStyle: TextDecorationStyle.double,
  ),
),

以下是其他TextDecorationStyle值:

TextDecorationStyle.dashed TextDecorationStyle.dotted TextDecorationStyle.double TextDecorationStyle.wavy

或者,为了防止复杂性,您也可以使用Flutter Markdown https://pub.dev/packages/flutter_markdown

你可以通过应用decoration: TextDecoration来实现。下划线到文本的TextStyle。

主题示例:

          Text(
            "text",
            style: Theme
                .of(context)
                .accentTextTheme
                .subhead
                .copyWith(decoration: TextDecoration.underline),
          )

基本的例子:

          Text(
            "text",
            style: TextStyle(decoration: TextDecoration.underline),
          )

你可以在样式中使用TextDecoration来强调给定的文本。

例如

Text(
    "Your text here",
    style: TextStyle(
        decoration: TextDecoration.underline),
    )
)

例如

Text(
  "Terms and Condition",
  style: TextStyle(
    decoration:
        TextDecoration.underline,
    height: 1.5,
    fontSize: 15,
    fontWeight: FontWeight.bold,
    fontFamily: 'Roboto-Regular',
  ),
),