TextLayoutCache class final
一份排版参数下的 TextPainter 池, 按 key 复用排版结果。
key 契约: 值相等语义, 且在当前 LabelStyle 下完全决定文本。可用 String、num、FlexiNum、record; 变长序列直接用 List: 本池按元素比较, 未命中入池时冻结一份副本, 调用方可以复用自己的 List。 可用宽度不进 key, 由 TextPainter.layout 自己判断约束是否变化。
- Implemented types
Constructors
- TextLayoutCache({int capacity = 1})
Properties
Methods
-
configure(
LabelStyle style) → void - 同步排版参数; 只有 LabelStyle.sameLayout 不成立时才清空。
-
dispose(
) → void -
释放原生资源(如 TextPainter 持有的 ui.Paragraph)。之后不可再用。
override
-
layout(
Object key, {Object build()?, double minWidth = 0, double maxWidth = double.infinity}) → TextPainter -
build为 null 时key本身就是文本(String 或 InlineSpan)。 -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
) → void -
丢弃缓存内容, 对象本身保留可继续使用。
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- debugMissCount ↔ int
-
全部实例累计的未命中次数, 即真正重设文本并排版的次数; 只在 debug 下累加, 供计数测试断言。
getter/setter pair