Remove getter for final operator

A getter for a final variable makes no sense, because the variable
cannot be reassigned. It is better to remove the unnecessary getter
and make the variable public.
pull/236/head
Till Friebe 4 years ago
parent 292609871c
commit 3b429840b6
  1. 12
      lib/src/widgets/cursor.dart
  2. 6
      lib/src/widgets/text_line.dart

@ -60,7 +60,7 @@ class CursorCont extends ChangeNotifier {
required CursorStyle style,
required TickerProvider tickerProvider,
}) : _style = style,
_blink = ValueNotifier(false),
blink = ValueNotifier(false),
color = ValueNotifier(style.color) {
_blinkOpacityCont =
AnimationController(vsync: tickerProvider, duration: _FADE_DURATION);
@ -68,17 +68,13 @@ class CursorCont extends ChangeNotifier {
}
final ValueNotifier<bool> show;
final ValueNotifier<bool> _blink;
final ValueNotifier<bool> blink;
final ValueNotifier<Color> color;
late AnimationController _blinkOpacityCont;
Timer? _cursorTimer;
bool _targetCursorVisibility = false;
CursorStyle _style;
ValueNotifier<bool> get cursorBlink => _blink;
ValueNotifier<Color> get cursorColor => color;
CursorStyle get style => _style;
set style(CursorStyle value) {
@ -93,7 +89,7 @@ class CursorCont extends ChangeNotifier {
stopCursorTimer();
_blinkOpacityCont.dispose();
show.dispose();
_blink.dispose();
blink.dispose();
color.dispose();
assert(_cursorTimer == null);
super.dispose();
@ -154,7 +150,7 @@ class CursorCont extends ChangeNotifier {
void _onColorTick() {
color.value = _style.color.withOpacity(_blinkOpacityCont.value);
_blink.value = show.value && _blinkOpacityCont.value > 0;
blink.value = show.value && _blinkOpacityCont.value > 0;
}
}

@ -575,7 +575,7 @@ class RenderEditableTextLine extends RenderEditableBox {
}
if (containsCursor()) {
cursorCont.addListener(markNeedsLayout);
cursorCont.cursorColor.addListener(markNeedsPaint);
cursorCont.color.addListener(markNeedsPaint);
}
}
@ -587,7 +587,7 @@ class RenderEditableTextLine extends RenderEditableBox {
}
if (containsCursor()) {
cursorCont.removeListener(markNeedsLayout);
cursorCont.cursorColor.removeListener(markNeedsPaint);
cursorCont.color.removeListener(markNeedsPaint);
}
}
@ -728,7 +728,7 @@ class RenderEditableTextLine extends RenderEditableBox {
_body,
cursorCont.style,
_caretPrototype,
cursorCont.cursorColor.value,
cursorCont.color.value,
devicePixelRatio,
);

Loading…
Cancel
Save