flutter - 如何在颤动中覆盖主题样式
问题描述
嗨,我需要文本样式,例如bodyText3
,像这样
bodyText3: TextStyle(
fontSize: 16,
height: 1.5,
fontWeight: FontWeight.w600,
color: MyColors.black)
但在颤振中,我们只有这种风格。
headline1,
headline2,
headline3,
headline4,
headline5,
headline6,
subtitle1,
subtitle2,
bodyText1,
bodyText2,
caption,
我应该怎么做才能添加我的新风格?
解决方案
创建一个常量来定义样式
const TextStyle bodyText3 = TextStyle(
fontSize: 14,
color: darkGrey,
fontWeight: FontWeight.w700,
);
在 Text 的 style 属性中使用此常量
Text(
'No',
style: bodyText3,
),
推荐阅读
- python - 如何使用 .txt 文件中的二进制输入绘制 PCM 波
- python - 为什么在推送到 Github 时会创建一个新的子目录
- python-3.x - 如果 HTML 标签位于 ::Before using bs4 下,如何提取文本
- java - 如何以编程方式检测android studio中的系统背景触摸
- scala - 如何使用 Scala 内核为 Jupyter notebook 安装 sbt 包?
- php - 如何在 Laravel 宏闭包中记录 $this?
- reactjs - 带有自定义 Thumb 组件的移动设备上 Material-ui 滑块的奇怪行为
- r - 为什么这些操作不会产生相同的结果?管道进入。(点)
- c# - 使您的表单输入文本控件具有合适的尺寸吗?
- reactjs - Typescript - 如何将类型定义添加到 React 经典组件