Skip to content

Commit 271e097

Browse files
committed
Fix issue that OverflowWidget not work well when the size of window is changing.
1 parent a1b22b7 commit 271e097

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
* Fix issue that setState() causes custom overflow to disappear(#171)
44
* Fix issue that can' find no overflow(#167,#174)
5+
* Fix issue that OverflowWidget not work well when the size of window is changing.
56

67
## 15.0.0
78

lib/src/extended/rendering/paragraph.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class ExtendedRenderParagraph extends _RenderParagraph
5353
_overflowWidget = overflowWidget;
5454
_canSelectPlaceholderSpan = canSelectPlaceholderSpan;
5555
_gradientConfig = gradientConfig;
56+
_textCache = text;
5657
}
5758

5859
@override
@@ -103,6 +104,9 @@ class ExtendedRenderParagraph extends _RenderParagraph
103104
ChildLayoutHelper.layoutChild,
104105
ChildLayoutHelper.getBaseline,
105106
);
107+
if (_textPainter.text != _textCache && _constraints != constraints) {
108+
_textPainter.text = _textCache;
109+
}
106110
_layoutTextWithConstraints(constraints);
107111
positionInlineChildren(_textPainter.inlinePlaceholderBoxes!);
108112

@@ -175,6 +179,7 @@ class ExtendedRenderParagraph extends _RenderParagraph
175179
_disposeSelectableFragments();
176180
_updateSelectionRegistrarSubscription();
177181
}
182+
_constraints = constraints;
178183
}
179184

180185
@override

lib/src/extended/text_overflow_mixin.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ mixin TextOverflowMixin on _RenderParagraph {
6666
markNeedsLayout();
6767
}
6868

69+
BoxConstraints? _constraints;
70+
InlineSpan? _textCache;
71+
72+
@override
73+
set text(InlineSpan value) {
74+
_textCache = value;
75+
super.text = value;
76+
}
77+
6978
void layoutOverflow() {
7079
// final bool didOverflowWidth = _didVisualOverflow();
7180
// layoutOfficalOverflow(didOverflowWidth);
@@ -147,7 +156,9 @@ mixin TextOverflowMixin on _RenderParagraph {
147156
final Size overflowWidgetSize = lastChild!.size;
148157
final TextOverflowPosition position = overflowWidget!.position;
149158

150-
final TextPainter oneLineTextPainter = _copyTextPainter();
159+
final TextPainter oneLineTextPainter = _copyTextPainter(
160+
inlineSpan: _textCache,
161+
);
151162

152163
final List<PlaceholderDimensions> placeholderDimensions =
153164
layoutInlineChildren(

0 commit comments

Comments
 (0)