当前位置: 首页 > news >正文

网站建设默认字体泗阳城乡建设局网站

网站建设默认字体,泗阳城乡建设局网站,开网站做备案需要什么资料,榆林网站建设电话flutter开发实战-RichText富文本居中对齐 在开发过程中,经常会使用到RichText,当使用RichText时候,不同文本字体大小默认没有居中对齐。这里记录一下设置过程。 一、使用RichText 我这里使用RichText设置不同字体大小的文本 Container(de…

flutter开发实战-RichText富文本居中对齐

在开发过程中,经常会使用到RichText,当使用RichText时候,不同文本字体大小默认没有居中对齐。这里记录一下设置过程。

一、使用RichText

我这里使用RichText设置不同字体大小的文本

Container(decoration: BoxDecoration(color: Colors.amber,),alignment: Alignment.center,child: RichText(textAlign: TextAlign.center,text: TextSpan(children: [TextSpan(text: 'Hello\s',style: TextStyle(fontSize: 30,)),TextSpan(text: 'Flutter',style: TextStyle(fontSize: 50),),TextSpan(text: 'let\s go',style: TextStyle(fontSize: 30,)),]),),),

在设置后发现文本没有在竖直方向没有居中对齐。
下面需要使用到WidgetSpan

WidgetSpan是官方提供用于针对图文混排的非常便捷的实现方式。WidgetSpan可以接入任何你需要的Widget。

在WidgetSpan支持在文本中插入指定的Widget,可以提升富文本自定义效果。

Text.rich(TextSpan(children: <InlineSpan>[TextSpan(text: 'Hello World!'),WidgetSpan(child: SizedBox(width: 100,height: 50,child: Card(color: Colors.red,child: Center(child: Text('flutter'))),)),TextSpan(text: '加油!'),],)

二、RichText富文本居中对齐

RichText富文本居中对齐,我们可以将文本进行使用WidgetSpan进行嵌套。

WidgetSpan buildCenteredTextSpan({required String text, required TextStyle style}) {return WidgetSpan(alignment: PlaceholderAlignment.middle,child: Text(text, style: style),);}

调整之后的代码如下

Container(decoration: BoxDecoration(color: Colors.amber,),alignment: Alignment.center,child: RichText(textAlign: TextAlign.center,text: TextSpan(children: [buildCenteredTextSpan(text: 'Hello\s', style: TextStyle(fontSize: 30,)),buildCenteredTextSpan(text: 'Flutter', style: TextStyle(fontSize: 50,)),buildCenteredTextSpan(text: ' let\s go', style: TextStyle(fontSize: 30,)),]),),),

效果图如下
在这里插入图片描述

三、小结

flutter开发实战-RichText富文本居中对齐

学习记录,每天不停进步。

http://www.yayakq.cn/news/655450/

相关文章:

  • 带询盘外贸网站源码品牌网络营销
  • 聊城做网站做的不错的网络公司新浪云wordpress
  • 上海网站建设备案号怎么恢复黑龙江住房和城乡建设部网站
  • html5网站开发案例网站备案核验系统
  • 太原定制网站开发制作seo站内优化和站外优化
  • 天津企业网站设计哪家好wordpress旋转文字
  • 成都网站制作在线搭建网站难吗
  • asp网站开发软件抖音seo排名软件
  • 广州建筑公司招聘网站西安网站建设-中国互联
  • 江西建设信息港网站网站登录设计欣赏
  • 域名购买后如何建设网站wordpress医疗模板
  • 郴州网站建设服务企业邮箱查询
  • 企业建设网站的资金策划唐山网站制作工具
  • 平面网站设计wordpress ip_hash失效
  • 优的网站建设明细报价表网站由哪些部分组成部分组成
  • wordpress去除下划线福州网站优化公司
  • 淘宝网站建设的特点广州网站建设定制价格
  • 做网站图片用什么格式最好深圳企业网站建设设计制作方案
  • 案例剖析网站有网站加金币的做弊器吗6
  • 昆山做网站的公司有哪些加盟高端网站建设
  • 网站在哪里建立做网站的好项目
  • 馨端网站建设seo薪资水平
  • 深圳哪里有做网站的阿里巴巴外贸订单网站
  • 做搜狗网站优化排wordpress 登录小工具
  • 做网站咋不用买虚拟机wordpress增加自适应功能
  • 宜宾做网站c 网站开发案例详解百度云
  • ps网站首页直线教程wordpress自动推送工具代码
  • 黄冈商城网站建设哪家好宝坻手机网站建设
  • 做app_需要先做网站吗东莞营销型网站
  • 石基网站建设wordpress 科技联盟