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)
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)
归档时间: |
|
查看次数: |
3500 次 |
最近记录: |