Committed by
David PHAM-VAN
Fixes crash when array is empty (no characters)
Showing
1 changed file
with
8 additions
and
2 deletions
@@ -503,10 +503,16 @@ class _Line { | @@ -503,10 +503,16 @@ class _Line { | ||
503 | 503 | ||
504 | final bool justify; | 504 | final bool justify; |
505 | 505 | ||
506 | - double get height => parent._spans | ||
507 | - .sublist(firstSpan, lastSpan) | 506 | + double get height { |
507 | + final list = parent._spans.sublist(firstSpan, lastSpan); | ||
508 | + if (list.length > 0) { | ||
509 | + return list | ||
508 | .reduce((a, b) => a.height > b.height ? a : b) | 510 | .reduce((a, b) => a.height > b.height ? a : b) |
509 | .height; | 511 | .height; |
512 | + } else { | ||
513 | + return 0; | ||
514 | + } | ||
515 | + } | ||
510 | 516 | ||
511 | @override | 517 | @override |
512 | String toString() => | 518 | String toString() => |
-
Please register or login to post a comment