setText method
Lays out textPainter. By default it remains owned by the caller.
Set owned to transfer ownership and release it on replacement/reset.
Implementation
void setText(TextPainter textPainter, String forKey, {bool owned = false}) {
_checkActive();
textPainter.textDirection ??= TextDirection.ltr;
textPainter.layout();
final alreadyOwned = _ownedText.values.any(
(item) => identical(item, textPainter),
);
final previous = _ownedText.remove(forKey);
if (owned || alreadyOwned) _ownedText[forKey] = textPainter;
if (previous != null &&
!identical(previous, textPainter) &&
!_ownedText.values.any((item) => identical(item, previous))) {
previous.dispose();
}
dynamicText[forKey] = textPainter;
notifyListeners();
}