Showing
4 changed files
with
23 additions
and
2 deletions
@@ -17,6 +17,7 @@ | @@ -17,6 +17,7 @@ | ||
17 | - Add blend mode | 17 | - Add blend mode |
18 | - Add soft mask | 18 | - Add soft mask |
19 | - Remove dependency to the deprecated utf library | 19 | - Remove dependency to the deprecated utf library |
20 | +- Fix RichText.maxLines with multiple TextSpan | ||
20 | 21 | ||
21 | ## 1.12.0 | 22 | ## 1.12.0 |
22 | 23 |
@@ -629,7 +629,7 @@ class RichText extends Widget { | @@ -629,7 +629,7 @@ class RichText extends Widget { | ||
629 | 629 | ||
630 | lines++; | 630 | lines++; |
631 | if (maxLines != null && lines > maxLines) { | 631 | if (maxLines != null && lines > maxLines) { |
632 | - break; | 632 | + return false; |
633 | } | 633 | } |
634 | 634 | ||
635 | offsetX = 0.0; | 635 | offsetX = 0.0; |
@@ -693,7 +693,7 @@ class RichText extends Widget { | @@ -693,7 +693,7 @@ class RichText extends Widget { | ||
693 | 693 | ||
694 | lines++; | 694 | lines++; |
695 | if (maxLines != null && lines > maxLines) { | 695 | if (maxLines != null && lines > maxLines) { |
696 | - break; | 696 | + return false; |
697 | } | 697 | } |
698 | 698 | ||
699 | offsetX = 0.0; | 699 | offsetX = 0.0; |
@@ -270,6 +270,26 @@ void main() { | @@ -270,6 +270,26 @@ void main() { | ||
270 | )); | 270 | )); |
271 | }); | 271 | }); |
272 | 272 | ||
273 | + test('Text Widgets RichText maxLines', () { | ||
274 | + final rnd = math.Random(42); | ||
275 | + final para = LoremText(random: rnd).paragraph(30); | ||
276 | + | ||
277 | + pdf.addPage( | ||
278 | + Page( | ||
279 | + build: (Context context) => RichText( | ||
280 | + maxLines: 3, | ||
281 | + text: TextSpan( | ||
282 | + text: para, | ||
283 | + children: List<TextSpan>.generate( | ||
284 | + 4, | ||
285 | + (index) => TextSpan(text: para), | ||
286 | + ), | ||
287 | + ), | ||
288 | + ), | ||
289 | + ), | ||
290 | + ); | ||
291 | + }); | ||
292 | + | ||
273 | tearDownAll(() { | 293 | tearDownAll(() { |
274 | final file = File('widgets-text.pdf'); | 294 | final file = File('widgets-text.pdf'); |
275 | file.writeAsBytesSync(pdf.save()); | 295 | file.writeAsBytesSync(pdf.save()); |
No preview for this file type
-
Please register or login to post a comment