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 CursorStyle style,
required TickerProvider tickerProvider, required TickerProvider tickerProvider,
}) : _style = style, }) : _style = style,
_blink = ValueNotifier(false), blink = ValueNotifier(false),
color = ValueNotifier(style.color) { color = ValueNotifier(style.color) {
_blinkOpacityCont = _blinkOpacityCont =
AnimationController(vsync: tickerProvider, duration: _FADE_DURATION); AnimationController(vsync: tickerProvider, duration: _FADE_DURATION);
@ -68,17 +68,13 @@ class CursorCont extends ChangeNotifier {
} }
final ValueNotifier<bool> show; final ValueNotifier<bool> show;
final ValueNotifier<bool> _blink; final ValueNotifier<bool> blink;
final ValueNotifier<Color> color; final ValueNotifier<Color> color;
late AnimationController _blinkOpacityCont; late AnimationController _blinkOpacityCont;
Timer? _cursorTimer; Timer? _cursorTimer;
bool _targetCursorVisibility = false; bool _targetCursorVisibility = false;
CursorStyle _style; CursorStyle _style;
ValueNotifier<bool> get cursorBlink => _blink;
ValueNotifier<Color> get cursorColor => color;
CursorStyle get style => _style; CursorStyle get style => _style;
set style(CursorStyle value) { set style(CursorStyle value) {
@ -93,7 +89,7 @@ class CursorCont extends ChangeNotifier {
stopCursorTimer(); stopCursorTimer();
_blinkOpacityCont.dispose(); _blinkOpacityCont.dispose();
show.dispose(); show.dispose();
_blink.dispose(); blink.dispose();
color.dispose(); color.dispose();
assert(_cursorTimer == null); assert(_cursorTimer == null);
super.dispose(); super.dispose();
@ -154,7 +150,7 @@ class CursorCont extends ChangeNotifier {
void _onColorTick() { void _onColorTick() {
color.value = _style.color.withOpacity(_blinkOpacityCont.value); 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()) { if (containsCursor()) {
cursorCont.addListener(markNeedsLayout); cursorCont.addListener(markNeedsLayout);
cursorCont.cursorColor.addListener(markNeedsPaint); cursorCont.color.addListener(markNeedsPaint);
} }
} }
@ -587,7 +587,7 @@ class RenderEditableTextLine extends RenderEditableBox {
} }
if (containsCursor()) { if (containsCursor()) {
cursorCont.removeListener(markNeedsLayout); cursorCont.removeListener(markNeedsLayout);
cursorCont.cursorColor.removeListener(markNeedsPaint); cursorCont.color.removeListener(markNeedsPaint);
} }
} }
@ -728,7 +728,7 @@ class RenderEditableTextLine extends RenderEditableBox {
_body, _body,
cursorCont.style, cursorCont.style,
_caretPrototype, _caretPrototype,
cursorCont.cursorColor.value, cursorCont.color.value,
devicePixelRatio, devicePixelRatio,
); );

Loading…
Cancel
Save