TDText class

文本控件 设计原则: 1.为了使用更方便,所以对系统组件进行的扩展,需兼容系统控件所有功能,不能让用户使用TDesign时,因不能满足系统功能而弃用。 2.非系统已有属性,尽量添加注释

需求:把一部分在TextStyle中的属性扁平化,放到外层。 1.暴露系统的所有属性,支持系统所有操作 2.约束使用主题配置的几种字体 3.提供转换为系统Text的方法,以使某些系统组件指定接收系统Text时可使用。(Image组件同理) 4.支持自定义TextStyle 5.兼容TextSpan形式

技巧: 命名参数替换属性的正则: 第一步,把Text中的可选参数拷贝过来,变成如下格式: Text(data, this.style, this.strutStyle, ……) 第二步,正则替换如下: 匹配(前半有默认值,后半无默认值):this.(a-z|A-Z+) \=+ a-z|A-Z+,|this.(a-z|A-Z+), 替换:$1$2: this.$1$2,

Inheritance

Constructors

TDText(dynamic data, {Font? font, FontWeight? fontWeight, FontFamily? fontFamily, Color textColor = Colors.black, Color? backgroundColor, bool? isTextThrough = false, Color? lineThroughColor = Colors.white, String? package, TextStyle? style, StrutStyle? strutStyle, TextAlign? textAlign, TextDirection? textDirection, Locale? locale, bool? softWrap, TextOverflow? overflow, double? textScaleFactor, int? maxLines, String? semanticsLabel, TextWidthBasis? textWidthBasis, TextHeightBehavior? textHeightBehavior, bool forceVerticalCenter = false, Key? key})
const
TDText.rich(InlineSpan? textSpan, {Font? font, FontWeight? fontWeight, FontFamily? fontFamily, Color textColor = Colors.black, Color? backgroundColor, bool? isTextThrough = false, Color? lineThroughColor = Colors.white, String? package, Key? key, TextStyle? style, StrutStyle? strutStyle, TextAlign? textAlign, TextDirection? textDirection, Locale? locale, bool? softWrap, TextOverflow? overflow, double? textScaleFactor, int? maxLines, String? semanticsLabel, TextWidthBasis? textWidthBasis, TextHeightBehavior? textHeightBehavior, bool forceVerticalCenter = false})
富文本构造方法
const

Properties

backgroundColor Color?
背景颜色
final
data → dynamic
以下系统text属性,释义请参考系统Text中注释
final
font Font?
字体尺寸,包含大小size和行高height
final
fontFamily FontFamily?
字体ttf
final
fontWeight FontWeight?
字体粗细
final
forceVerticalCenter bool
final
hashCode int
The hash code for this object.
no setterinherited
isTextThrough bool?
是否是横线穿过样式(删除线)
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
lineThroughColor Color?
删除线颜色,对应TestStyle的decorationColor
final
locale Locale?
final
maxLines int?
final
overflow TextOverflow?
final
package String?
字体包名
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
semanticsLabel String?
final
softWrap bool?
final
strutStyle StrutStyle?
final
style TextStyle?
自定义的TextStyle,其中指定的属性,将覆盖扩展的外层属性
final
textAlign TextAlign?
final
textColor Color
文本颜色
final
textDirection TextDirection?
final
textHeightBehavior TextHeightBehavior?
final
textScaleFactor double?
final
textSpan InlineSpan?
final
textWidthBasis TextWidthBasis?
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
getConfiguration(BuildContext context) TDTextConfiguration?
提取成方法,允许业务定义自己的TDTextConfiguration
getRawText({BuildContext? context}) Text
获取系统原始Text,以便使用到只能接收系统Text组件的地方 转化为系统原始Text后,将失去padding和background属性
getTextStyle(BuildContext? context, {double? height, Color? backgroundColor}) TextStyle?
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited