You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you select a InputFormField the keyboard automatically gets requested and is shown. There is actually no way to make it dismiss from the UI and it's unclear or not possible to do it from current widgets.
Reacted by Deborah Speece, Mahmood Janabi, Ihor Klimov, Gregor, samueldeschamps, Miklos Nemeth, Ricko, Franze M, Karl, Benjith Kizhisseri and 4 more
Reacted by pltlg, Tom-De-Backer, Franze M and Kazi Mehedi Hasan
@chinmaygarde The .close() method is not static on that class, which means I need to access it on an instance member. However the constructor is private, so I can't create an instance member.
I'm come across an error with the about implementation. As you'll see from the below images, I'm using code to dismiss the keyboard by calling Focus.clear(context);.
I'm not sure how unfocusing dismisses the keyboard, as in, precisely what flutter is doing under the hood.
The effect of being 'focused' is still in effect on the InputFormField widget.
Reacted by Luca Romagnoli, Günter Zöchbauer, VolodymyrVA, ROTGP, Ben-Hur Santos Ott, Norm Glomski, CodeSphere Solutions, Ihor Klimov, Victor Camargo, Frank Morfin and 23 more
Reacted by Gibson, Sherif Abdelhay, Maurizio Lucci, Bartosz Dołęga and Chinaski
Reacted by Aboo, MagicSource, Ralph Bergmann, aspiratfk, Günter Zöchbauer, Sri Prasanna, Jorge Noguera, Bartlomiej Tartanus, Tan Jun Xiang, DopplerRedshift and 107 more
Reacted by donnerstag, Chandu J S, Zafranudin Zafrin, Katekko, Vlad, tegkev, Long Thay ™, vishnyakov-aleks, tanmaysathe, Craig Labenz and 9 more
Reacted by Saeed Hashem, Mateus Gustavo de Freitas e Silva, Chandu J S, Zafranudin Zafrin, Aditya Sodhani, Katekko, Rody Davis, Karl, vishnyakov-aleks, Breno Prata and 13 more
@jifalops have you tried without currentFocus != WidgetsBinding.instance.focusManager.rootScope?
I just wrote an article on this topic that contains the full code. I'm curious if there's something different about your approach as this works for me.
Yes I tried it without checking the rootScope, but from what I gather, calling unfocus() on the root scope causes an exception. My use case involves hiding the keyboard when the text field gains focus, which is a bit more stringent than most use cases.
On Sun, Aug 4, 2019 at 1:22 PM Jacob Phillips ***@***.***> wrote:
To show the date/time picker dialogs instead of initially going into edit
mode. https://pub.dev/packages/datetime_picker_formfield
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#7247?email_source=notifications&email_token=AAA24IV53W7O4EK3VCVTZNLQC4T6LA5CNFSM4CZQJVGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3QH6SQ#issuecomment-518029130>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAA24IX2HX2ED4AHK2ZMZOTQC4T6LANCNFSM4CZQJVGA>
.
@jifalops@jamesdixon If unfocus() is not working then pay VERY close attention to which BuildContext you have passed in to the FocusScope.of(context).
In particular I made the mistake of using the BuildContext passed into a build method rather than the context supplied from a Builder function, my particular case the function was building up a MaterialPageRoute so the context was well out of expected scope by the time the builder was called i.e.
Is there any way to actually manipulate the keyboard hide button on android? just like in android there is onConfigurationChanged, i want to decrease/increase image size when the keyboard is shown/hidden.
There is a few points to mention and put into light here :
Nobody ever mentioned that the solution proned by everyone to reset the focus basically conflicts with text editing options (the 'copy/paste/select all' menus).
For exemple :
Hold a tap on a text to make the contextual text editing options appear on your device and try to use the 'select all' option, your focus is now reseted because of the fix and the text is unselected.
For this particular concerns the preferred method for me has been :
SystemChannels.textInput.invokeMethod('TextInput.hide');
We dropped it since first iterations but i already been experiencing with reactions to long press by wrapping the whole app with a Listener with onPointerDown and onPointerUp event listeners. You can evaluate the timing between down and up events to recognize and differentiate long press/scrollings.
A way to know which particular Widget is the target of focus on tap would come in really handy too.
Something like :
'FocusScope.of(context).componentType' which would answer 'TextFormField'.
I couldn't find a way to get this informations (from my experimentations at least, correct me if i'm wrong).
Also the missing Done button on iOs numeric keyboards in Flutter is kind of a problem, your one and only option to dismiss the keyboard is then to use the solutions detailed in this thread. Which does seem kind of hacky-wacky.
Thought i'd leave these points here if anybody would ever need them.
@Ladriel, you can indeed get the runtime type of the widget that has the current focus:
Type focusedType =Focus.of(context).context.widget.runtimeType;
But this is a question that would be better asked on Stack Overflow.
As for your other comments, please file separate bugs for separate issues.
I'm going to close this bug for comments, since the issue database isn't really the best place for conversation or questions: the bug has been closed for a long time.
Activity
eseidelGoogle commentedon Dec 13, 2016
@Hixie or @mpcomplete presumably this is a docs bug?
Hixie commentedon Dec 13, 2016
Assuming this means how to do it from code, I guess so.
mikemimik commentedon Dec 13, 2016
When you select a
InputFormFieldthe keyboard automatically gets requested and is shown. There is actually no way to make it dismiss from the UI and it's unclear or not possible to do it from current widgets.Hixie commentedon Dec 13, 2016
From the UI it's easy, just press the Android OS-level down arrow button (replaces the back button when the keyboard is up).
mikemimik commentedon Dec 13, 2016
I'm working in iOS and there is no such OS-level trigger. I tested in the simulator and on device, I get the same standard keyboard.
chinmaygarde commentedon Dec 13, 2016
TextInputConnection.closeshould do what you need.mikemimik commentedon Dec 15, 2016
@chinmaygarde The
.close()method is not static on that class, which means I need to access it on an instance member. However the constructor is private, so I can't create an instance member.mikemimik commentedon Dec 15, 2016
I figured out how to do it. In discussion with @eseidelGoogle, posed the question if unfocusing might do the trick.
Inside a section of code which has access to the
contextyou just need to haveFocus.clear(context);and it will dismiss the keyboard.mikemimik commentedon Dec 15, 2016
I'm come across an error with the about implementation. As you'll see from the below images, I'm using code to dismiss the keyboard by calling
Focus.clear(context);.The effect of being 'focused' is still in effect on the
InputFormFieldwidget.Unselected input:
Selected input:
Dismissed keyboard:
sethladd commentedon Dec 17, 2016
@mikemimik did you ever get this to work? What was your recipe?
mikemimik commentedon Apr 11, 2017
@sethladd Will cycle back to this on the weekend. Apologies for being so terribly behind on responding.
pedia commentedon Nov 3, 2017
I found HACK way:
and call
jonasbark commentedon Nov 30, 2017
This is a better way, as it also clears the focus:
FocusScope.of(context).requestFocus(new FocusNode());from
https://stackoverflow.com/a/44991969/1068346
69 remaining items
jamesdixon commentedon Aug 4, 2019
@jifalops have you tried without
currentFocus != WidgetsBinding.instance.focusManager.rootScope?I just wrote an article on this topic that contains the full code. I'm curious if there's something different about your approach as this works for me.
jifalops commentedon Aug 4, 2019
Yes I tried it without checking the
rootScope, but from what I gather, calling unfocus() on the root scope causes an exception. My use case involves hiding the keyboard when the text field gains focus, which is a bit more stringent than most use cases.jifalops commentedon Aug 4, 2019
@jamesdixon That is a clever way to unfocus any input in the app when tapping outside of them.
jamesdixon commentedon Aug 4, 2019
@jifalops thanks! out of curiosity, what's your use case for hiding the keyboard when the form field gains focus?
jifalops commentedon Aug 4, 2019
To show the date/time picker dialogs instead of initially going into edit mode. https://pub.dev/packages/datetime_picker_formfield
jamesdixon commentedon Aug 4, 2019
JamesMcIntosh commentedon Aug 28, 2019
@jifalops @jamesdixon If
unfocus()is not working then pay VERY close attention to which BuildContext you have passed in to theFocusScope.of(context).In particular I made the mistake of using the BuildContext passed into a build method rather than the context supplied from a Builder function, my particular case the function was building up a MaterialPageRoute so the context was well out of expected scope by the time the builder was called i.e.
awkaw commentedon Nov 22, 2019
import 'package:flutter/services.dart';
SystemChannels.textInput.invokeMethod('TextInput.hide');
BahijMik commentedon Dec 14, 2019
Is there any way to actually manipulate the keyboard hide button on android? just like in android there is onConfigurationChanged, i want to decrease/increase image size when the keyboard is shown/hidden.
malviyaritesh commentedon Dec 27, 2019
As mentioned in #7247 (comment)
Now, simply you can
unfocusalso:m-rahme commentedon Jan 29, 2020
If i have a
TextFieldimplemented in a Stack withGoogleMapswidget,FocusScope.of(context).unfocus();will not work. Any Solution ?TKH219 commentedon Feb 21, 2020
WidgetsBinding.instance.focusManager.primaryFocus?.unfocus();
You should try it.
Ladriel commentedon Mar 2, 2020
There is a few points to mention and put into light here :
Nobody ever mentioned that the solution proned by everyone to reset the focus basically conflicts with text editing options (the 'copy/paste/select all' menus).
For exemple :
Hold a tap on a text to make the contextual text editing options appear on your device and try to use the 'select all' option, your focus is now reseted because of the fix and the text is unselected.
For this particular concerns the preferred method for me has been :
SystemChannels.textInput.invokeMethod('TextInput.hide');
We dropped it since first iterations but i already been experiencing with reactions to long press by wrapping the whole app with a Listener with onPointerDown and onPointerUp event listeners. You can evaluate the timing between down and up events to recognize and differentiate long press/scrollings.
A way to know which particular Widget is the target of focus on tap would come in really handy too.
Something like :
'FocusScope.of(context).componentType' which would answer 'TextFormField'.
I couldn't find a way to get this informations (from my experimentations at least, correct me if i'm wrong).
Also the missing Done button on iOs numeric keyboards in Flutter is kind of a problem, your one and only option to dismiss the keyboard is then to use the solutions detailed in this thread. Which does seem kind of hacky-wacky.
Thought i'd leave these points here if anybody would ever need them.
gspencergoog commentedon Mar 11, 2020
@Ladriel, you can indeed get the runtime type of the widget that has the current focus:
But this is a question that would be better asked on Stack Overflow.
As for your other comments, please file separate bugs for separate issues.
I'm going to close this bug for comments, since the issue database isn't really the best place for conversation or questions: the bug has been closed for a long time.