_visibility in TextSelection is not nullable

pull/630/head
X Code 3 years ago
parent 5b7d865074
commit b3c627f7a9
  1. 14
      lib/src/widgets/text_selection.dart

@ -430,12 +430,14 @@ class _TextSelectionHandleOverlay extends StatefulWidget {
_TextSelectionHandleOverlayState createState() =>
_TextSelectionHandleOverlayState();
ValueListenable<bool>? get _visibility {
ValueListenable<bool> get _visibility {
switch (position) {
case _TextSelectionHandlePosition.START:
return renderObject!.selectionStartInViewport;
case _TextSelectionHandlePosition.END:
return renderObject!.selectionEndInViewport;
default:
throw 'Invalid position';
}
}
}
@ -457,11 +459,11 @@ class _TextSelectionHandleOverlayState
duration: const Duration(milliseconds: 150), vsync: this);
_handleVisibilityChanged();
widget._visibility!.addListener(_handleVisibilityChanged);
widget._visibility.addListener(_handleVisibilityChanged);
}
void _handleVisibilityChanged() {
if (widget._visibility!.value) {
if (widget._visibility.value) {
_controller.forward();
} else {
_controller.reverse();
@ -471,14 +473,14 @@ class _TextSelectionHandleOverlayState
@override
void didUpdateWidget(_TextSelectionHandleOverlay oldWidget) {
super.didUpdateWidget(oldWidget);
oldWidget._visibility!.removeListener(_handleVisibilityChanged);
oldWidget._visibility.removeListener(_handleVisibilityChanged);
_handleVisibilityChanged();
widget._visibility!.addListener(_handleVisibilityChanged);
widget._visibility.addListener(_handleVisibilityChanged);
}
@override
void dispose() {
widget._visibility!.removeListener(_handleVisibilityChanged);
widget._visibility.removeListener(_handleVisibilityChanged);
_controller.dispose();
super.dispose();
}

Loading…
Cancel
Save