Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

隐藏键盘报错,但不影响使用,直接运行example也是如此 #64

Closed
weiwill opened this issue Mar 25, 2021 · 1 comment
Closed

Comments

@weiwill
Copy link

weiwill commented Mar 25, 2021

版本: cool_ui: ^1.0.0

E/MethodChannel#flutter/textinput(12311): Failed to handle method call
E/MethodChannel#flutter/textinput(12311): java.lang.NullPointerException: Attempt to invoke virtual method 'void io.flutter.plugin.editing.ListenableEditingState.removeEditingStateListener(io.flutter.plugin.editing.ListenableEditingState$EditingStateWatcher)' on a null object reference
E/MethodChannel#flutter/textinput(12311): 	at io.flutter.plugin.editing.TextInputPlugin.clearTextInputClient(TextInputPlugin.java:530)
E/MethodChannel#flutter/textinput(12311): 	at io.flutter.plugin.editing.TextInputPlugin$1.clearClient(TextInputPlugin.java:151)
E/MethodChannel#flutter/textinput(12311): 	at io.flutter.embedding.engine.systemchannels.TextInputChannel$1.onMethodCall(TextInputChannel.java:114)
E/MethodChannel#flutter/textinput(12311): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#flutter/textinput(12311): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#flutter/textinput(12311): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/MethodChannel#flutter/textinput(12311): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#flutter/textinput(12311): 	at android.os.MessageQueue.next(MessageQueue.java:386)
E/MethodChannel#flutter/textinput(12311): 	at android.os.Looper.loop(Looper.java:175)
E/MethodChannel#flutter/textinput(12311): 	at android.app.ActivityThread.main(ActivityThread.java:7625)
E/MethodChannel#flutter/textinput(12311): 	at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter/textinput(12311): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
E/MethodChannel#flutter/textinput(12311): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
E/flutter (12311): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'void io.flutter.plugin.editing.ListenableEditingState.removeEditingStateListener(io.flutter.plugin.editing.ListenableEditingState$EditingStateWatcher)' on a null object reference, null, java.lang.NullPointerException: Attempt to invoke virtual method 'void io.flutter.plugin.editing.ListenableEditingState.removeEditingStateListener(io.flutter.plugin.editing.ListenableEditingState$EditingStateWatcher)' on a null object reference
E/flutter (12311): 	at io.flutter.plugin.editing.TextInputPlugin.clearTextInputClient(TextInputPlugin.java:530)
E/flutter (12311): 	at io.flutter.plugin.editing.TextInputPlugin$1.clearClient(TextInputPlugin.java:151)
E/flutter (12311): 	at io.flutter.embedding.engine.systemchannels.TextInputChannel$1.onMethodCall(TextInputChannel.java:114)
E/flutter (12311): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/flutter (12311): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/flutter (12311): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/flutter (12311): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (12311): 	at android.os.MessageQueue.next(MessageQueue.java:386)
E/flutter (12311): 	at android.os.Looper.loop(Looper.java:175)
E/flutter (12311): 	at android.app.ActivityThread.main(ActivityThread.java:7625)
E/flutter (12311): 	at java.lang.reflect.Method.invoke(Native Method)
E/flutter (12311): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
E/flutter (12311): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
E/flutter (12311): )
E/flutter (12311): #0      JSONMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:164:7)
E/flutter (12311): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158:18)
E/flutter (12311): <asynchronous suspension>
E/flutter (12311): 
@weiwill
Copy link
Author

weiwill commented Mar 26, 2021

需要隐藏键盘时,调用
FocusScope.of(context).requestFocus(FocusNode());

FocusScope.of(context).unfocus();
都会出现上述错误
好像时用这种方式隐藏键盘,会调用openKeyboard()方法

因为需要点击空白,隐藏键盘,所以需要以上面的方式去隐藏键盘

目前使用下面隐藏键盘的方式可以避过这个问题
SystemChannels.textInput.invokeMethod('TextInput.hide');

@weiwill weiwill closed this as completed Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant