文本对齐无法与 RichText 一起正常工作

Dee*_*lot 7 richtext dart flutter

我正在使用RichText并且在本文中RichText使用任何带有样式的文本跨度时,justify 无法正常工作decoration: TextDecoration.underline

RichText(
          softWrap: true,
          textAlign: TextAlign.justify,
          text: TextSpan(
            style: TextStyle(
              color: Colors.black,
              fontWeight: FontWeight.w500,
              fontSize: 16.0,
            ),
            children: getSpan(),
          ),
        )
Run Code Online (Sandbox Code Playgroud)
List<TextSpan> getSpan() {
    List<TextSpan> spans = List<TextSpan>();
    spans.add(TextSpan(
      text:
      "And thus We made them rise ",
    ));
    spans.add(
      TextSpan(
          text: " they ",
          style: TextStyle(
             decoration: TextDecoration.underline,
          ),
          recognizer: TapGestureRecognizer()
            ..onTap = () {
              print("click on me");
            }),
    );
    spans.add(TextSpan(
      text:
      " And thus We made them rise ",
    ));
    return spans;
  }
Run Code Online (Sandbox Code Playgroud)

看看剩下的

att*_*ona 2

It looks like a nasty effect of textAlign property when set to TextAlign.justify.

RichText(
          softWrap: true,
          //textAlign: TextAlign.justify,
          text: TextSpan(
            style: TextStyle(
              color: Colors.black,
              fontWeight: FontWeight.w500,
              fontSize: 16.0,
            ),
            children: getSpan(),
          ),
        )
Run Code Online (Sandbox Code Playgroud)

Updated to 21/03/19

The bug it is now fixed and at the moment (21/03/19) it is available in the master flutter channel:

flutter channel master
Run Code Online (Sandbox Code Playgroud)