[fix]: cursorConnt.color notify the text_line to repaint if it was disposed (#428)

pull/429/head
appflowy 4 years ago committed by GitHub
parent d1320c4236
commit aea3159ddc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      lib/src/widgets/text_line.dart

@ -413,7 +413,7 @@ class RenderEditableTextLine extends RenderEditableBox {
color = c;
if (containsTextSelection()) {
markNeedsPaint();
safeMarkNeedsPaint();
}
}
@ -425,7 +425,7 @@ class RenderEditableTextLine extends RenderEditableBox {
final containsSelection = containsTextSelection();
if (attached && containsCursor()) {
cursorCont.removeListener(markNeedsLayout);
cursorCont.color.removeListener(markNeedsPaint);
cursorCont.color.removeListener(safeMarkNeedsPaint);
}
textSelection = t;
@ -433,11 +433,11 @@ class RenderEditableTextLine extends RenderEditableBox {
_containsCursor = null;
if (attached && containsCursor()) {
cursorCont.addListener(markNeedsLayout);
cursorCont.color.addListener(markNeedsPaint);
cursorCont.color.addListener(safeMarkNeedsPaint);
}
if (containsSelection || containsTextSelection()) {
markNeedsPaint();
safeMarkNeedsPaint();
}
}
@ -642,7 +642,7 @@ class RenderEditableTextLine extends RenderEditableBox {
}
if (containsCursor()) {
cursorCont.addListener(markNeedsLayout);
cursorCont.color.addListener(markNeedsPaint);
cursorCont.color.addListener(safeMarkNeedsPaint);
}
}
@ -654,7 +654,7 @@ class RenderEditableTextLine extends RenderEditableBox {
}
if (containsCursor()) {
cursorCont.removeListener(markNeedsLayout);
cursorCont.color.removeListener(markNeedsPaint);
cursorCont.color.removeListener(safeMarkNeedsPaint);
}
}
@ -883,6 +883,14 @@ class RenderEditableTextLine extends RenderEditableBox {
affinity: position.affinity,
);
}
void safeMarkNeedsPaint() {
if (!attached) {
//Should not paint if it was unattach.
return;
}
safeMarkNeedsPaint();
}
}
class _TextLineElement extends RenderObjectElement {

Loading…
Cancel
Save