【发布时间】:2020-12-28 10:48:53
【问题描述】:
我想将文本居中对齐,但如果文本占用两行,则无法正常工作。看图片。白色的文字可以正常工作,但蓝色的文字不起作用。
Container(
decoration: new BoxDecoration(color: Color(int.parse(bgColor.replaceAll('#', '0xff')))),
alignment: Alignment.center,
padding: EdgeInsets.fromLTRB(0, 100, 0, 100),
child: ParsedText(
text: text,
style: part == "big" ? TextStyle(
fontWeight: FontWeight.bold,
fontSize: 30,
color: color
):
TextStyle(
color: Colors.black
),
parse: <MatchText>[
MatchText(
type: ParsedType.URL,
style: TextStyle(color: Colors.blue,),
onTap: (url) async{
url = "http://"+url.replaceAll("https://", "");
if (await canLaunch(url)) await launch(url);
}
)
]
),
)
【问题讨论】:
-
如果您使用简单的字符串而不是
ParsedText、MatchedText等内容,会容易得多。 -
我必须使用
ParsedText和MatchedText因为我想测试我的文本是否包含用于创建可点击链接的url -
textAlign: TextAlign.center -
我不使用
Text()所以textAlign: TextAlign.center不起作用 -
检查下面的答案
标签: flutter