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

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

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

Loading…
Cancel
Save