Skip to content

Commit a1b22b7

Browse files
committed
Fix issue that can' find no overflow(#167,#174))
1 parent 2a526fc commit a1b22b7

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

CHANGELOG.md

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

33
* Fix issue that setState() causes custom overflow to disappear(#171)
4+
* Fix issue that can' find no overflow(#167,#174)
45

56
## 15.0.0
67

lib/src/extended/text_overflow_mixin.dart

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -455,12 +455,17 @@ mixin TextOverflowMixin on _RenderParagraph {
455455

456456
if (_hasVisualOverflow) {
457457
// not find
458-
assert(range.end != maxOffset, 'can\' find no overflow');
458+
// assert(range.end != maxOffset, 'can\' find no overflow');
459+
final _TextRange pre = range.copyWith();
459460
range.end = math.min(
460-
range.end + 1
461-
// math.max((maxEnd - range.end) ~/ 2, 1)
462-
,
463-
maxOffset);
461+
// range.end + 1,
462+
range.end + math.max((maxEnd - range.end) ~/ 2, 1),
463+
maxOffset,
464+
);
465+
if (pre == range) {
466+
_hasVisualOverflow = false;
467+
break;
468+
}
464469
hideWidgets.clear();
465470
} else {
466471
// see pre one whether overflow
@@ -477,12 +482,11 @@ mixin TextOverflowMixin on _RenderParagraph {
477482
} else {
478483
maxEnd = range.end;
479484
range.end = math.max(
480-
range.start,
481-
maxEnd - 1,
482-
// math.min(
483-
// math.max((maxEnd - range.start) ~/ 2, 1),
484-
// maxEnd)
485-
);
485+
range.start,
486+
// maxEnd - 1,
487+
math.min(
488+
maxEnd - math.max((maxEnd - range.start) ~/ 2, 1), maxEnd));
489+
486490
// if range is not changed, so maybe we should break.
487491
if (pre == range) {
488492
_hasVisualOverflow = false;

0 commit comments

Comments
 (0)