Remove null exception when a disposed controller is set

pull/239/head
Till Friebe 4 years ago
parent 1fedaf0d13
commit 4c11b28cb9
  1. 12
      lib/src/widgets/cursor.dart

@ -139,10 +139,18 @@ class CursorCont extends ChangeNotifier {
notifyListeners();
}
/// True when this [CursorCont] instance has been disposed.
///
/// A safety mechanism to prevent the value of a disposed controller from
/// getting set.
bool _isDisposed = false;
@override
void dispose() {
_blinkOpacityController.removeListener(_onColorTick);
stopCursorTimer();
_isDisposed = true;
_blinkOpacityController.dispose();
show.dispose();
blink.dispose();
@ -174,6 +182,10 @@ class CursorCont extends ChangeNotifier {
}
void startCursorTimer() {
if (_isDisposed) {
return;
}
_targetCursorVisibility = true;
_blinkOpacityController.value = 1.0;

Loading…
Cancel
Save