flutter
flutter copied to clipboard
RawKeyboardListener & Focus onKey callback doesn't working on IOS (reproduce on Iphone 6 & Iphone13 pro)
onKey Callback from RawKeyboardListener and Focus Widget not working on iphone6 & Iphone 13 pro. But in the simulator it works fine. Only Iphone6 & Iphone13 pro reproduces this problem.
Steps to Reproduce
try run this code on Iphone6 & Iphone13 pro
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'RawKeyboardListener onKey error',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
late FocusNode _focusNode;
@override
void initState() {
super.initState();
_focusNode = FocusNode();
}
@override
void dispose() {
_focusNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("RawKeybaordListener onKey error"),
),
body: RawKeyboardListener(
focusNode: _focusNode,
onKey: (event) {
// doesn't working
print(event);
},
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const <Widget>[
TextField(),
],
),
),
),
);
}
}
flutter doctor
[✓] Flutter (Channel stable, 3.0.5, on macOS 12.4 21F79 darwin-arm, locale ko-KR) • Flutter version 3.0.5 • Upstream repository https://github.com/flutter/flutter.git • Framework revision f1875d570e (9 days ago), 2022-07-13 11:24:16 -0700 • Engine revision e85ea0e79c • Dart version 2.17.6 • DevTools version 2.12.2 [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK • Platform android-31, build-tools 30.0.3 • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 13.4.1) • Xcode at /Applications/Xcode.app/Contents/Developer • CocoaPods version 1.11.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2020.3) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: :hammer: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: :hammer: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189) [✓] VS Code (version 1.69.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.44.0
Thanks for the report @SungHyun22 What's the expected result are you looking for after running code sample ?
Our team pressed the enter key and the backspace key on the keyboard. But onKey callback does not print any events. Our team reproduced this problem from iPhone 6 and iPhone 13 Pro. In addition, iPhone simulators, Galaxy Note 5, and Galaxy S9 confirmed that onKey callback was working properly
Thanks for the update @SungHyun22. According to this merged PR : https://github.com/flutter/flutter/pull/101537, can you try using Focus
widget instead of RawKeyboardListener
and see if you get desired behavior on same devices ?
Thank you for response @darshankawar. We already test using focus. But the result is same. onKey callback doesn't work. 😥😥
Thanks for the update. Running code sample on iPhone 6s with latest stable and master doesn't show onKey
press events:
Syncing files to device Darshan's iphone...
fopen failed for data file: errno = 2 (No such file or directory)
Errors found! Invalidating cache...
fopen failed for data file: errno = 2 (No such file or directory)
Errors found! Invalidating cache...
But the same is shown on iOS simulator:
Debug service listening on ws://127.0.0.1:49854/ujh5hvC6nJU=/ws
Syncing files to device iPhone 13...
flutter: RawKeyDownEvent#a5091(logicalKey: LogicalKeyboardKey#00106(keyId: "0x200000106", keyLabel: "Meta Left", debugName: "Meta Left"), physicalKey: PhysicalKeyboardKey#700e3(usbHidUsage: "0x000700e3", debugName: "Meta Left"), repeat: false)
flutter: RawKeyDownEvent#36cbb(logicalKey: LogicalKeyboardKey#000b8(keyId: "0x13000000b8", keyLabel: "", debugName: "Key with ID 0x013000000b8"), physicalKey: PhysicalKeyboardKey#000b8(usbHidUsage: "0x13000000b8", debugName: "Key with ID 0x13000000b8"), repeat: false)
flutter: RawKeyUpEvent#1c6b9(logicalKey: LogicalKeyboardKey#000b8(keyId: "0x13000000b8", keyLabel: "", debugName: "Key with ID 0x013000000b8"), physicalKey: PhysicalKeyboardKey#000b8(usbHidUsage: "0x13000000b8", debugName: "Key with ID 0x13000000b8"))
flutter: RawKeyUpEvent#790b2(logicalKey: LogicalKeyboardKey#00106(keyId: "0x200000106", keyLabel: "Meta Left", debugName: "Meta Left"), physicalKey: PhysicalKeyboardKey#700e3(usbHidUsage: "0x000700e3", debugName: "Meta Left"))
stable, master flutter doctor -v
[✓] Flutter (Channel stable, 3.0.5, on macOS 12.2.1 21D62 darwin-x64, locale
en-GB)
• Flutter version 3.0.5 at /Users/dhs/documents/fluttersdk/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f1875d570e (2 days ago), 2022-07-13 11:24:16 -0700
• Engine revision e85ea0e79c
• Dart version 2.17.6
• DevTools version 2.12.2
[!] Xcode - develop for iOS and macOS (Xcode 12.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
! Flutter recommends a minimum Xcode version of 13.
Download the latest version or update via the Mac App Store.
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] VS Code (version 1.62.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.21.0
[✓] Connected device (5 available)
• SM G975F (mobile) • RZ8M802WY0X • android-arm64 • Android 11 (API 30)
• Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 •
ios • iOS 14.4.1 18D61
• iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729 •
ios • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
• macOS (desktop) • macos •
darwin-x64 • Mac OS X 10.15.4 19E2269 darwin-x64
• Chrome (web) • chrome •
web-javascript • Google Chrome 98.0.4758.80
[✓] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 1 category.
[✓] Flutter (Channel master, 3.1.0-0.0.pre.1894, on macOS 12.2.1 21D62
darwin-x64, locale en-GB)
• Flutter version 3.1.0-0.0.pre.1894 on channel master at
/Users/dhs/documents/fluttersdk/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f48478a21b (88 minutes ago), 2022-07-26 23:38:06 -0400
• Engine revision 609f1abf0f
• Dart version 2.19.0 (build 2.19.0-36.0.dev)
• DevTools version 2.15.0
[!] Xcode - develop for iOS and macOS (Xcode 12.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
! Flutter recommends a minimum Xcode version of 13.
Download the latest version or update via the Mac App Store.
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] VS Code (version 1.62.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.21.0
[✓] Connected device (5 available)
• SM G975F (mobile) • RZ8M802WY0X • android-arm64 • Android 11 (API 30)
• Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 •
ios • iOS 14.4.1 18D61
• iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729 •
ios • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
• macOS (desktop) • macos •
darwin-x64 • Mac OS X 10.15.4 19E2269 darwin-x64
• Chrome (web) • chrome •
web-javascript • Google Chrome 98.0.4758.80
[✓] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 1 category.
CC @dkwingsmt
anything update here?
I'm having this problem, too.
Is there still no way to solve it?
@antholeole @chinmaygarde @dkwingsmt
any update on this ?
Any progress? Currently, I have only tested on iPhone 8 and iPhone 14. The Focus.onKey method responds to operations on the physical keyboard, but not to operations on the on-screen keyboard.
I'm having the same problem. Any updates on the issue?
mark
same issue here, any update?
I am also facing same issue , any update ?
Please upvote original issue description instead of asking for updates. The issue has high chances of getting attention based on number of upvotes.
The new KeyboardListener still has this problem
Any workaround or fix for this?
Waiting for a response