fix: flutter anlayze (#730)
This commit is contained in:
parent
a52a2e7990
commit
d4d35c0d10
26 changed files with 36 additions and 231 deletions
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
|
|
@ -33,7 +33,7 @@ jobs:
|
|||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: "stable"
|
||||
flutter-version: "3.16.2"
|
||||
flutter-version: "3.19.0"
|
||||
cache: true
|
||||
|
||||
- name: Run tests
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ class _HomePageState extends State<HomePage> {
|
|||
html.toJson(),
|
||||
).toString(),
|
||||
);
|
||||
if (mounted) {
|
||||
if (context.mounted) {
|
||||
_loadEditor(context, jsonString);
|
||||
}
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -229,7 +229,6 @@ class UpdateTextOperation extends Operation {
|
|||
int get hashCode => delta.hashCode ^ inverted.hashCode;
|
||||
}
|
||||
|
||||
// TODO(Lucas.Xu): refactor this part
|
||||
Path transformPath(Path preInsertPath, Path b, [int delta = 1]) {
|
||||
if (preInsertPath.length > b.length || preInsertPath.isEmpty || b.isEmpty) {
|
||||
return b;
|
||||
|
|
@ -269,6 +268,5 @@ Operation? transformOperation(Operation a, Operation b) {
|
|||
return b.copyWith(path: newPath);
|
||||
}
|
||||
|
||||
// TODO: transform update and textedit
|
||||
return b;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -368,7 +368,6 @@ extension TextTransaction on Transaction {
|
|||
);
|
||||
}
|
||||
|
||||
// TODO: refactor this code
|
||||
void replaceTexts(
|
||||
List<Node> nodes,
|
||||
Selection selection,
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ class _TodoListBlockComponentWidgetState
|
|||
});
|
||||
|
||||
if (widget.toggleChildrenTriggers != null &&
|
||||
RawKeyboard.instance.keysPressed.any(
|
||||
HardwareKeyboard.instance.logicalKeysPressed.any(
|
||||
(element) => widget.toggleChildrenTriggers!.contains(element),
|
||||
)) {
|
||||
checkOrUncheckChildren(!checked, widget.node);
|
||||
|
|
|
|||
|
|
@ -186,7 +186,6 @@ extension SelectionTransform on EditorState {
|
|||
|
||||
/// move the cursor forward.
|
||||
///
|
||||
/// TODO: I think we should add move forward function to the SelectableMixin.
|
||||
/// Don't hardcode the logic here.
|
||||
/// For example,
|
||||
/// final position = node.selectable?.moveForward(selection.startIndex);
|
||||
|
|
|
|||
|
|
@ -92,8 +92,6 @@ class DeltaTextInputService extends TextInputService with DeltaTextInputClient {
|
|||
apply(textEditingDeltas);
|
||||
}
|
||||
|
||||
// TODO: support IME in linux / windows / ios / android
|
||||
// Only support macOS now.
|
||||
@override
|
||||
void updateCaretPosition(Size size, Matrix4 transform, Rect rect) {
|
||||
_textInputConnection
|
||||
|
|
|
|||
|
|
@ -118,8 +118,6 @@ class NonDeltaTextInputService extends TextInputService with TextInputClient {
|
|||
_textInputConnection = null;
|
||||
}
|
||||
|
||||
// TODO: support IME in linux / ios / android
|
||||
// Only verify in macOS and Windows now.
|
||||
@override
|
||||
void updateCaretPosition(Size size, Matrix4 transform, Rect rect) {
|
||||
_textInputConnection
|
||||
|
|
|
|||
|
|
@ -17,10 +17,6 @@ import 'package:flutter/material.dart';
|
|||
/// ```
|
||||
///
|
||||
abstract class AppFlowyKeyboardService {
|
||||
/// Processes shortcut key input.
|
||||
@Deprecated('Not used anymore')
|
||||
KeyEventResult onKey(RawKeyEvent event);
|
||||
|
||||
/// Enables shortcuts service.
|
||||
void enable();
|
||||
|
||||
|
|
|
|||
|
|
@ -133,9 +133,6 @@ class KeyboardServiceWidgetState extends State<KeyboardServiceWidget>
|
|||
_attachTextInputService(selection);
|
||||
}
|
||||
|
||||
@override
|
||||
KeyEventResult onKey(RawKeyEvent event) => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget child = widget.child;
|
||||
|
|
@ -145,7 +142,7 @@ class KeyboardServiceWidgetState extends State<KeyboardServiceWidget>
|
|||
// the Focus widget is used to handle hardware keyboard.
|
||||
child = Focus(
|
||||
focusNode: focusNode,
|
||||
onKey: _onKey,
|
||||
onKeyEvent: _onKeyEvent,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
|
@ -165,8 +162,9 @@ class KeyboardServiceWidgetState extends State<KeyboardServiceWidget>
|
|||
}
|
||||
|
||||
/// handle hardware keyboard
|
||||
KeyEventResult _onKey(FocusNode node, RawKeyEvent event) {
|
||||
if (event is! RawKeyDownEvent || !enableShortcuts) {
|
||||
KeyEventResult _onKeyEvent(FocusNode node, KeyEvent event) {
|
||||
if ((event is! KeyDownEvent && event is! KeyRepeatEvent) ||
|
||||
!enableShortcuts) {
|
||||
if (textInputService.composingTextRange != TextRange.empty) {
|
||||
return KeyEventResult.skipRemainingHandlers;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,14 +74,10 @@ class _MobileScrollServiceState extends State<MobileScrollService>
|
|||
}
|
||||
|
||||
@override
|
||||
void jumpToTop() {
|
||||
// TODO: implement jumpToTop
|
||||
}
|
||||
void jumpToTop() {}
|
||||
|
||||
@override
|
||||
void jumpToBottom() {
|
||||
// TODO: implement jumpToBottom
|
||||
}
|
||||
void jumpToBottom() {}
|
||||
|
||||
@override
|
||||
void disable() {
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ class _DesktopSelectionServiceWidgetState
|
|||
}
|
||||
|
||||
Selection? selection;
|
||||
if (RawKeyboard.instance.isShiftPressed && _panStartOffset != null) {
|
||||
if (HardwareKeyboard.instance.isShiftPressed && _panStartOffset != null) {
|
||||
final first = getNodeInOffset(_panStartOffset!)?.selectable;
|
||||
|
||||
if (first != null) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:appflowy_editor/src/editor/editor_component/service/shortcuts/character_shortcut_event.dart';
|
||||
import 'package:appflowy_editor/src/editor/command/transform.dart';
|
||||
import 'package:appflowy_editor/src/editor/editor_component/service/shortcuts/character_shortcut_event.dart';
|
||||
import 'package:appflowy_editor/src/editor/util/util.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
|
|
@ -19,7 +19,8 @@ final CharacterShortcutEvent insertNewLine = CharacterShortcutEvent(
|
|||
CharacterShortcutEventHandler _insertNewLineHandler = (editorState) async {
|
||||
// on desktop or web, shift + enter to insert a '\n' character to the same line.
|
||||
// so, we should return the false to let the system handle it.
|
||||
if (PlatformExtension.isNotMobile && RawKeyboard.instance.isShiftPressed) {
|
||||
if (PlatformExtension.isNotMobile &&
|
||||
HardwareKeyboard.instance.isShiftPressed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,7 +94,6 @@ Future<bool> _showSlashMenu(
|
|||
// show the slash menu
|
||||
() {
|
||||
// this code is copied from the the old editor.
|
||||
// TODO: refactor this code
|
||||
final context = editorState.getNodeAtPath(selection.start.path)?.context;
|
||||
if (context != null) {
|
||||
_selectionMenuService = SelectionMenu(
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ final CommandShortcutEvent openInlineLinkCommand = CommandShortcutEvent(
|
|||
KeyEventResult _openInlineLink(
|
||||
EditorState editorState,
|
||||
) {
|
||||
//TODO:If selection is collapsed, isHref is false.
|
||||
final selection = editorState.selection;
|
||||
if (selection == null || selection.isCollapsed) {
|
||||
return KeyEventResult.ignored;
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ class CommandShortcutEvent {
|
|||
}
|
||||
}
|
||||
|
||||
bool canRespondToRawKeyEvent(RawKeyEvent event) {
|
||||
bool canRespondToRawKeyEvent(KeyEvent event) {
|
||||
return keybindings.containsKeyEvent(event);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import 'package:appflowy_editor/appflowy_editor.dart';
|
|||
import 'package:appflowy_editor/src/service/default_text_operations/format_rich_text_style.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
// TODO: this file is too long, need to refactor.
|
||||
abstract class SelectionMenuService {
|
||||
Offset get offset;
|
||||
Alignment get alignment;
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ class _SelectionMenuWidgetState extends State<SelectionMenuWidget> {
|
|||
Widget build(BuildContext context) {
|
||||
return Focus(
|
||||
focusNode: _focusNode,
|
||||
onKey: _onKey,
|
||||
onKeyEvent: _onKeyEvent,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: widget.selectionMenuStyle.selectionMenuBackgroundColor,
|
||||
|
|
@ -382,9 +382,10 @@ class _SelectionMenuWidgetState extends State<SelectionMenuWidget> {
|
|||
/// Handles arrow keys to switch selected items
|
||||
/// Handles keyword searches
|
||||
/// Handles enter to select item and esc to exit
|
||||
KeyEventResult _onKey(FocusNode node, RawKeyEvent event) {
|
||||
KeyEventResult _onKeyEvent(FocusNode node, KeyEvent event) {
|
||||
Log.keyboard.debug('slash command, on key $event');
|
||||
if (event is! RawKeyDownEvent) {
|
||||
|
||||
if (event is! KeyDownEvent) {
|
||||
return KeyEventResult.ignored;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,10 +83,10 @@ class _LinkMenuState extends State<LinkMenu> {
|
|||
}
|
||||
|
||||
Widget _buildInput() {
|
||||
return RawKeyboardListener(
|
||||
return KeyboardListener(
|
||||
focusNode: FocusNode(),
|
||||
onKey: (key) {
|
||||
if (key is RawKeyDownEvent &&
|
||||
onKeyEvent: (key) {
|
||||
if (key is KeyDownEvent &&
|
||||
key.logicalKey == LogicalKeyboardKey.escape) {
|
||||
widget.onDismiss();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,8 +77,6 @@ class _BackgroundColorOptionsWidgetsState
|
|||
e.colorHex,
|
||||
);
|
||||
});
|
||||
} else {
|
||||
// TODO(yijing): handle when no text is selected
|
||||
}
|
||||
},
|
||||
isSelected: isSelected,
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue