Fix send on enter on mobile
This commit is contained in:
parent
ffe879680d
commit
e5062683e8
1 changed files with 7 additions and 10 deletions
|
|
@ -1,4 +1,3 @@
|
||||||
import "dart:io";
|
|
||||||
import "package:flutter/material.dart";
|
import "package:flutter/material.dart";
|
||||||
import "package:flutter/services.dart";
|
import "package:flutter/services.dart";
|
||||||
import "package:flutter_chat_core/flutter_chat_core.dart";
|
import "package:flutter_chat_core/flutter_chat_core.dart";
|
||||||
|
|
@ -55,16 +54,11 @@ class ChatBox extends HookConsumerWidget {
|
||||||
|
|
||||||
final node = useFocusNode(
|
final node = useFocusNode(
|
||||||
onKeyEvent: (_, event) {
|
onKeyEvent: (_, event) {
|
||||||
if (event is KeyDownEvent && !Platform.isAndroid && !Platform.isIOS) {
|
if (event is KeyDownEvent &&
|
||||||
if (event.logicalKey == LogicalKeyboardKey.enter &&
|
event.logicalKey == LogicalKeyboardKey.escape) {
|
||||||
!HardwareKeyboard.instance.isShiftPressed) {
|
|
||||||
send();
|
|
||||||
return KeyEventResult.handled;
|
|
||||||
} else if (event.logicalKey == LogicalKeyboardKey.escape) {
|
|
||||||
onDismiss();
|
onDismiss();
|
||||||
return KeyEventResult.handled;
|
return KeyEventResult.handled;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return KeyEventResult.ignored;
|
return KeyEventResult.ignored;
|
||||||
},
|
},
|
||||||
|
|
@ -156,6 +150,9 @@ class ChatBox extends HookConsumerWidget {
|
||||||
),
|
),
|
||||||
controller: controller.value,
|
controller: controller.value,
|
||||||
key: key,
|
key: key,
|
||||||
|
// TODO: Setting for send on enter on / off
|
||||||
|
onFieldSubmitted: (_) => send(),
|
||||||
|
textInputAction: TextInputAction.done,
|
||||||
focusNode: node,
|
focusNode: node,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue