Fix incorrect double to int cast, and guard against optional parent (#239)

pull/241/head
hyouuu 4 years ago committed by GitHub
parent 2b9d6bd71b
commit c63831d014
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      lib/src/models/documents/nodes/node.dart
  2. 8
      lib/src/widgets/text_line.dart

@ -53,6 +53,9 @@ abstract class Node extends LinkedListEntry<Node> {
/// Offset in characters of this node in the document.
int get documentOffset {
if (parent == null) {
return offset;
}
final parentOffset = (parent is! Root) ? parent!.documentOffset : 0;
return parentOffset + offset;
}

@ -625,11 +625,11 @@ class RenderEditableTextLine extends RenderEditableBox {
final verticalPadding = _resolvedPadding!.top + _resolvedPadding!.bottom;
final leadingWidth = _leading == null
? 0
: _leading!.getMinIntrinsicWidth(height - verticalPadding) as int;
: _leading!.getMinIntrinsicWidth(height - verticalPadding).floor();
final bodyWidth = _body == null
? 0
: _body!.getMinIntrinsicWidth(math.max(0, height - verticalPadding))
as int;
.floor();
return horizontalPadding + leadingWidth + bodyWidth;
}
@ -640,11 +640,11 @@ class RenderEditableTextLine extends RenderEditableBox {
final verticalPadding = _resolvedPadding!.top + _resolvedPadding!.bottom;
final leadingWidth = _leading == null
? 0
: _leading!.getMaxIntrinsicWidth(height - verticalPadding) as int;
: _leading!.getMaxIntrinsicWidth(height - verticalPadding).ceil();
final bodyWidth = _body == null
? 0
: _body!.getMaxIntrinsicWidth(math.max(0, height - verticalPadding))
as int;
.ceil();
return horizontalPadding + leadingWidth + bodyWidth;
}

Loading…
Cancel
Save