TxExpandableText class

在文本超出指定行数之后,会显示 展开/收起 按钮的文本展示组件

用例1: 常规使用 TxExpandableText( '一大段文字...', collapsedLines: 2, textStyle: TextStyle(color: Colors.blue), )

用例2:特性化使用-比如 一段文字结尾显示的是 编辑,而点击编辑按钮之后要做一些事, 且显示样式不变 TxExpandableText( '一大段文字...', collapsedLines: 2, // 这两个长度也要设置一致 textStyle: TextStyle(color: Colors.blue), collapseButtonLabel: '编辑', expandable: false, // 设置为不可展开 onToggle: onToggle, // 执行按钮操作事件 )

Inheritance

Constructors

TxExpandableText.new(String data, {Key? key, int? collapsedLines, int? maxLines, TextStyle? style, String? collapseButtonLabel, String? expandButtonLabel, Widget? collapseIcon, Widget? expandIcon, Color? toggleButtonForegroundColor, TextStyle? toggleButtonTextStyle, bool? expanded, bool expandable = true, StrutStyle? strutStyle, TextAlign? textAlign, TextDirection? textDirection, Locale? locale, bool? softWrap, TextScaler? textScaler, String? semanticsLabel, TextWidthBasis? textWidthBasis, TextHeightBehavior? textHeightBehavior, Color? selectionColor, ValueChanged<bool>? onToggle, TxTextOverflow? overflow})
创建可展开文本小部件。
const

Properties

collapseButtonLabel String?
折叠按钮文字
final
collapsedLines int?
文本折叠后的行数
final
collapseIcon Widget?
折叠按钮
final
data String
要显示的文本。
final
expandable bool
是否可展开
final
expandButtonLabel String?
展开按钮文字
final
expanded bool?
是否展开
final
expandIcon Widget?
展开按钮
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
locale Locale?
参考 Text.locale
final
maxLines int?
文本展开后的最大显示行数
final
onToggle ValueChanged<bool>?
展开/折叠切换回调
final
overflow TxTextOverflow?
文字溢出时处理方式
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selectionColor Color?
参考 Text.selectionColor
final
semanticsLabel String?
参考 Text.semanticsLabel
final
softWrap bool?
参考 Text.softWrap
final
strutStyle StrutStyle?
参考 Text.strutStyle
final
style TextStyle?
如果非空,则此文本使用的样式。
final
textAlign TextAlign?
参考 Text.textAlign
final
textDirection TextDirection?
参考 Text.textDirection
final
textHeightBehavior TextHeightBehavior?
参考 Text.textHeightBehavior
final
textScaler TextScaler?
参考 Text.textScaler 获得的 MediaQueryData.textScaler,如果范围内没有 MediaQuery,则为 1.0。
final
textWidthBasis TextWidthBasis?
参考 Text.textWidthBasis
final
toggleButtonForegroundColor Color?
展开/折叠按钮的文字颜色
final
toggleButtonTextStyle TextStyle?
展开/折叠按钮的文字样式
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<TxExpandableText>
Creates the mutable state for this widget at a given location in the tree.
override
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
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