From 949fdd76f2f6ac599777aea747faa9c96db2b694 Mon Sep 17 00:00:00 2001 From: X Code Date: Thu, 3 Feb 2022 23:34:32 -0800 Subject: [PATCH] Upgrade to flutter 2.10 --- lib/src/widgets/raw_editor.dart | 57 ++++++--------------------------- 1 file changed, 10 insertions(+), 47 deletions(-) diff --git a/lib/src/widgets/raw_editor.dart b/lib/src/widgets/raw_editor.dart index 473eea10..edbf26c8 100644 --- a/lib/src/widgets/raw_editor.dart +++ b/lib/src/widgets/raw_editor.dart @@ -233,7 +233,6 @@ class RawEditorState extends EditorState AutomaticKeepAliveClientMixin, WidgetsBindingObserver, TickerProviderStateMixin, - TextEditingActionTarget, RawEditorStateTextInputClientMixin, RawEditorStateSelectionDelegateMixin { final GlobalKey _editorKey = GlobalKey(); @@ -256,7 +255,6 @@ class RawEditorState extends EditorState // Focus bool _didAutoFocus = false; - FocusAttachment? _focusAttachment; bool get _hasFocus => widget.focusNode.hasFocus; // Theme @@ -280,7 +278,6 @@ class RawEditorState extends EditorState @override Widget build(BuildContext context) { assert(debugCheckHasMediaQuery(context)); - _focusAttachment!.reparent(); super.build(context); var _doc = widget.controller.document; @@ -568,7 +565,7 @@ class RawEditorState extends EditorState }); } - _focusAttachment = widget.focusNode.attach(context); + // Focus widget.focusNode.addListener(_handleFocusChanged); } @@ -612,8 +609,6 @@ class RawEditorState extends EditorState if (widget.focusNode != oldWidget.focusNode) { oldWidget.focusNode.removeListener(_handleFocusChanged); - _focusAttachment?.detach(); - _focusAttachment = widget.focusNode.attach(context); widget.focusNode.addListener(_handleFocusChanged); updateKeepAlive(); } @@ -651,7 +646,6 @@ class RawEditorState extends EditorState _selectionOverlay = null; widget.controller.removeListener(_didChangeTextEditingValue); widget.focusNode.removeListener(_handleFocusChanged); - _focusAttachment!.detach(); _cursorCont.dispose(); _clipboardStatus ..removeListener(_onChangedClipboardStatus) @@ -828,8 +822,15 @@ class RawEditorState extends EditorState /// This property is typically used to notify the renderer of input gestures. @override RenderEditor get renderEditor => - _editorKey.currentContext?.findRenderObject() as RenderEditor; + _editorKey.currentContext!.findRenderObject() as RenderEditor; + /// Express interest in interacting with the keyboard. + /// + /// If this control is already attached to the keyboard, this function will + /// request that the keyboard become visible. Otherwise, this function will + /// ask the focus system that it become focused. If successful in acquiring + /// focus, the control will then attach to the keyboard and request that the + /// keyboard become visible. @override void requestKeyboard() { if (_hasFocus) { @@ -840,24 +841,6 @@ class RawEditorState extends EditorState } } - @override - void setTextEditingValue( - TextEditingValue value, SelectionChangedCause cause) { - if (value == textEditingValue) { - return; - } - textEditingValue = value; - userUpdateTextEditingValue(value, cause); - - // keyboard and text input force a selection completion - _handleSelectionCompleted(); - } - - @override - void debugAssertLayoutUpToDate() { - renderEditor.debugAssertLayoutUpToDate(); - } - /// Shows the selection toolbar at the location of the current cursor. /// /// Returns `false` if a toolbar couldn't be shown, such as when the toolbar @@ -885,8 +868,7 @@ class RawEditorState extends EditorState widget.controller.copiedImageUrl = null; _pastePlainText = widget.controller.getPlainText(); _pasteStyle = widget.controller.getAllIndividualSelectionStyles(); - // Copied straight from EditableTextState - super.copySelection(cause); + if (cause == SelectionChangedCause.toolbar) { bringIntoView(textEditingValue.selection.extent); hideToolbar(false); @@ -911,8 +893,6 @@ class RawEditorState extends EditorState _pastePlainText = widget.controller.getPlainText(); _pasteStyle = widget.controller.getAllIndividualSelectionStyles(); - // Copied straight from EditableTextState - super.cutSelection(cause); if (cause == SelectionChangedCause.toolbar) { bringIntoView(textEditingValue.selection.extent); hideToolbar(); @@ -938,9 +918,6 @@ class RawEditorState extends EditorState return; } - // Copied straight from EditableTextState - super.pasteText(cause); // ignore: unawaited_futures - if (cause == SelectionChangedCause.toolbar) { bringIntoView(textEditingValue.selection.extent); hideToolbar(); @@ -949,8 +926,6 @@ class RawEditorState extends EditorState @override void selectAll(SelectionChangedCause cause) { - // Copied straight from EditableTextState - super.selectAll(cause); if (cause == SelectionChangedCause.toolbar) { bringIntoView(textEditingValue.selection.extent); } @@ -959,18 +934,6 @@ class RawEditorState extends EditorState @override bool get wantKeepAlive => widget.focusNode.hasFocus; - @override - bool get obscureText => false; - - @override - bool get selectionEnabled => widget.enableInteractiveSelection; - - @override - bool get readOnly => widget.readOnly; - - @override - TextLayoutMetrics get textLayoutMetrics => renderEditor; - @override AnimationController get floatingCursorResetController => _floatingCursorResetController;