问题描述
我正在尝试在我的应用中创建法律页面,例如条款和条件以及隐私政策页面。
Flutter是否有专门设计的小部件,除了使用默认的“文本”小部件以外,还可以接受长格式的文本?还是对此有破解?也许是从文本文件中读取内容?
我试图避免在dart文件中使用多个“文本”小部件来显示我的长格式法律页面。
谢谢。
解决方法
Expanded(
child: Text(
'a long text',overflow: TextOverflow.clip,),
如果文本中有各种样式,则可以使用RichText
RichText(
overflow: TextOverflow.clip
text: TextSpan(
text: 'Hello ',style: DefaultTextStyle.of(context).style,children: <TextSpan>[
TextSpan(text: 'Super long bolded text here',style: TextStyle(fontWeight: FontWeight.bold)),TextSpan(text: 'Super long unbolded text here'),],)