Second step of updating deprecated code

pull/1746/head
Ellet 1 year ago
parent ff3a0c8b4e
commit f3e8098af1
  1. 19
      lib/src/widgets/editor/editor.dart
  2. 2
      lib/src/widgets/others/default_styles.dart
  3. 16
      lib/src/widgets/raw_editor/raw_editor_state.dart

@ -307,10 +307,10 @@ class QuillEditorState extends State<QuillEditor>
// that might interfere with the editor key behavior, such as // that might interfere with the editor key behavior, such as
// SingleChildScrollView. Thanks to @wliumelb for the workaround. // SingleChildScrollView. Thanks to @wliumelb for the workaround.
// See issue https://github.com/singerdmx/flutter-quill/issues/304 // See issue https://github.com/singerdmx/flutter-quill/issues/304
return RawKeyboardListener( return KeyboardListener(
onKey: (_) {}, onKeyEvent: (_) {},
focusNode: FocusNode( focusNode: FocusNode(
onKey: (node, event) => KeyEventResult.skipRemainingHandlers, onKeyEvent: (node, event) => KeyEventResult.skipRemainingHandlers,
), ),
child: editor, child: editor,
); );
@ -453,10 +453,11 @@ class _QuillEditorSelectionGestureDetectorBuilder
} }
bool isShiftClick(PointerDeviceKind deviceKind) { bool isShiftClick(PointerDeviceKind deviceKind) {
final pressed = RawKeyboard.instance.keysPressed;
return deviceKind == PointerDeviceKind.mouse && return deviceKind == PointerDeviceKind.mouse &&
(pressed.contains(LogicalKeyboardKey.shiftLeft) || (HardwareKeyboard.instance
pressed.contains(LogicalKeyboardKey.shiftRight)); .isLogicalKeyPressed(LogicalKeyboardKey.shiftLeft) ||
HardwareKeyboard.instance
.isLogicalKeyPressed(LogicalKeyboardKey.shiftRight));
} }
@override @override
@ -739,8 +740,10 @@ class RenderEditor extends RenderEditableContainerBox
} }
bool get _shiftPressed => bool get _shiftPressed =>
RawKeyboard.instance.keysPressed.contains(LogicalKeyboardKey.shiftLeft) || HardwareKeyboard.instance
RawKeyboard.instance.keysPressed.contains(LogicalKeyboardKey.shiftRight); .isLogicalKeyPressed(LogicalKeyboardKey.shiftLeft) ||
HardwareKeyboard.instance
.isLogicalKeyPressed(LogicalKeyboardKey.shiftRight);
void setStartHandleLayerLink(LayerLink value) { void setStartHandleLayerLink(LayerLink value) {
if (_startHandleLayerLink == value) { if (_startHandleLayerLink == value) {

@ -1,5 +1,3 @@
import 'dart:ui';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../models/documents/attribute.dart'; import '../../models/documents/attribute.dart';

@ -14,7 +14,7 @@ import 'package:flutter/services.dart'
ClipboardData, ClipboardData,
HardwareKeyboard, HardwareKeyboard,
LogicalKeyboardKey, LogicalKeyboardKey,
RawKeyDownEvent, KeyDownEvent,
SystemChannels, SystemChannels,
TextInputControl; TextInputControl;
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart' import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart'
@ -782,7 +782,7 @@ class QuillRawEditorState extends EditorState
}), }),
child: Focus( child: Focus(
focusNode: widget.configurations.focusNode, focusNode: widget.configurations.focusNode,
onKey: _onKey, onKeyEvent: _onKeyEvent,
child: QuillKeyboardListener( child: QuillKeyboardListener(
child: Container( child: Container(
constraints: constraints, constraints: constraints,
@ -796,13 +796,15 @@ class QuillRawEditorState extends EditorState
); );
} }
KeyEventResult _onKey(node, RawKeyEvent event) { KeyEventResult _onKeyEvent(node, KeyEvent event) {
// Don't handle key if there is a meta key pressed. // Don't handle key if there is a meta key pressed.
if (event.isAltPressed || event.isControlPressed || event.isMetaPressed) { if (HardwareKeyboard.instance.isAltPressed ||
HardwareKeyboard.instance.isControlPressed ||
HardwareKeyboard.instance.isMetaPressed) {
return KeyEventResult.ignored; return KeyEventResult.ignored;
} }
if (event is! RawKeyDownEvent) { if (event is! KeyDownEvent) {
return KeyEventResult.ignored; return KeyEventResult.ignored;
} }
// Handle indenting blocks when pressing the tab key. // Handle indenting blocks when pressing the tab key.
@ -824,7 +826,7 @@ class QuillRawEditorState extends EditorState
return KeyEventResult.ignored; return KeyEventResult.ignored;
} }
KeyEventResult _handleSpaceKey(RawKeyEvent event) { KeyEventResult _handleSpaceKey(KeyEvent event) {
final child = final child =
controller.document.queryChild(controller.selection.baseOffset); controller.document.queryChild(controller.selection.baseOffset);
if (child.node == null) { if (child.node == null) {
@ -855,7 +857,7 @@ class QuillRawEditorState extends EditorState
return KeyEventResult.handled; return KeyEventResult.handled;
} }
KeyEventResult _handleTabKey(RawKeyEvent event) { KeyEventResult _handleTabKey(KeyEvent event) {
final child = final child =
controller.document.queryChild(controller.selection.baseOffset); controller.document.queryChild(controller.selection.baseOffset);

Loading…
Cancel
Save