
图片是网上找的,具体实现如下:
_buildClause() {
return Padding(
padding: const EdgeInsets.only(bottom: 20.0),
child: RichText(
maxLines: 2,
text: TextSpan(
text: '完成登录即代表您已阅读并同意"',
style: TextStyle(fontSize: 14.0, color: Colors.grey),
children: <TextSpan>[
TextSpan(
text: '服务条款',
style: TextStyle(
fontSize: 14.0,
color:Color(0xFFD37957),
decoration: TextDecoration.underline
),
recognizer: recognizer),
TextSpan(
text: '"',
style: TextStyle(fontSize: 14.0, color: Colors.grey),
)
])),
);
}
注意:TextStyle是设置文字的样式,TextDecoration的属性,比如
lineThrough 在每行文字中画一条线 (删除线) none 不做任何事情 overline 在每行文本上方画一条线 (上划线) underline 在每行文本下面画一条线(下划线)
要实现点击高亮文字需要一个:TapGestureRecognizer
final TapGestureRecognizer recognizer = TapGestureRecognizer();
然后在initState里面进行监听
recognizer.onTap = () {
_goCluasePage();
};
本文介绍如何在Flutter应用的登录页面中实现服务条款文本的高亮显示,并通过TapGestureRecognizer响应点击事件,跳转至详细条款页面。文章详细解释了使用RichText、TextSpan与TextStyle组件设置文本样式及装饰,以及监听器的配置。
891

被折叠的 条评论
为什么被折叠?



