On Flutter web with VoiceOver focus issue with TextFormFields - flutter

On flutter web, with VoiceOver on TextFormFields do not consistently get focus.
Please refer to the image. Observe that the accessibility focus has moved to second input while the input cursor is still on the first.
Please refer to the code at https://github.com/mfdcoder/flutter-form-voiceover
Steps to reproduce
Switch on Voiceover Using Ctl + Option + Right arrow navigate to the
TextFormField Continue navigating to 2nd, 3rd and 4th TextFormField
Observe that voice over announces that "You are in a text field. To enter text in this field type".
The input that has focus often does not accept what the user is typing.
The result is not consistent. The TextFormFields randomly get/don't get focus
The same can be reproduced on the flutter gallery demo app
https://gallery.flutter.dev/#/demo/text-field
Doctor summary (to see all details, run flutter doctor -v):
Flutter (Channel stable, 3.7.0, on macOS 12.5 21G72 darwin-x64, locale en-IN)
Android toolchain - develop for Android devices (Android SDK version 33.0.0)
Xcode - develop for iOS and macOS (Xcode 14.1)
Chrome - develop for the web
Android Studio (version 2021.2)
VS Code (version 1.75.1)
Connected device (5 available)
HTTP Host Availability
Accessibility focus and form focus do not match
Semantics(
focusable: true,
focused: _addressLine2.hasFocus,
child: TextFormField(
autovalidateMode: AutovalidateMode.onUserInteraction,
controller: _addressLine2Controller,
keyboardType: TextInputType.text,
textInputAction: TextInputAction.next,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter some text in line 2';
}
return null;
},
inputFormatters: [LengthLimitingTextInputFormatter(255)],
decoration: const InputDecoration(
hintText: 'Address Line 2',
labelText: 'Address Line 2',
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(6)),
borderSide: BorderSide(color: Colors.red),
)),
focusNode: _addressLine2,
onSaved: (value) {
_city.requestFocus();
},
),
),

Related

Does Flutter DropdownMenu support helper and error text (like DropdownButtonFormField's decoration)?

I'm trying to implement the new Material 3 DropdownMenu in my application to replace the old DropdownButton, but I can't seem to find where to add the error and helper texts.
Back in the DropdownButtonFormField, they would go inside the decoration parameter. Example:
decoration: InputDecoration(
labelText: 'labelText',
errorText: 'errorMessage',
helperText: 'helperText',
),
I could find the style parameters for both helper and error texts in the DropdownMenu, but not the parameter for the text itself.
Am I missing something or this widget does not support those parameters?
This was my DropdownButton before:
DropdownButtonFormField<MyItem>(
value: _selectedItem,
decoration: const InputDecoration(
labelText: 'Salutation',
errorText: 'errorMessage',
helperText: 'helperText',
border: OutlineInputBorder(),
),
onChanged: _onChanged,
items: items.map((MyItem item) {
return DropdownMenuItem<MyItem>(
value: item,
child: Text(item.title),
);
}).toList(),
);
The expected result with the DropdownMenu is a similar, but with the lowered position of the items menu and the integrated search feature it has. Those were the main reasons for the change.
For anyone needing this in the future, I opened an issue in the Flutter repository and they replied that the parameters are missing and will potentially be added.
Here is the link for the issue.

KeyboardType namePhonePad in Flutter

In iOS, we have keyboard type namePhonePad and the Normal behavior of this keyboard type is as shown in the below snapshot.
and the output is, (This is what I want in Flutter)
This is the output of iOS's namePhonePad keyboard type.
I want the same behavior for the flutter keyboard type.
I have reviewed and there is no namePhonePad keyboard type in a flutter. We have separate types like phone, number, name, etc,
but not namePhonePad
Flutter's output is,
You should try the package keyboard_actions
You can use the keyboardType of TextFormField widget with TextInputType.number and FilteringTextInputFormatter.digitsOnly... example:
Expanded(
child: TextFormField(
controller: txt_identidad,
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.digitsOnly
],
),
),

Prevent user from clicking on "." in the numeric keypad after having a decimal point already existing in the textfield in flutter

I have a TextField that i am using to get a double in my flutter app. The TextField uses number keypad.
child: TextField(
style: TextStyle(color: Colors.white),
inputFormatters: [FilteringTextInputFormatter.allow(new RegExp("[0-9.]"))],
controller: controller,
keyboardType: TextInputType.number,
decoration: textDecorator,
onSubmitted: () {
//Some Action
},
),
I have used inputformatter to prevent user from clicking on other punctuations as shown in the code. My issue is i am able to enter something like "23.45.3" which is basically having two "." symbols which should not be allowed. Ideally after "23.", if the user tries to click "." from the keypad again it should be disabled.
Any help on how to do this is appreciated.

How to show Keyboard?

I ask you a question regarding Flutter UI.
I want to show keyboard in ios simulator, but I cannot see.
Could you tell me how to show keyboard in ios simulator?
child: Column(
children: [
TextFormField(
autofocus: true,
textInputAction: TextInputAction.next,
decoration: InputDecoration(
labelText: 'タイトル',
),
validator: (String value) {
if (value.trim().isEmpty) {
return 'タイトル is required';
}
},
),
You should be able to toggle the software keyboard (the one on your simulator) by pressing cmd + k. This is assuming that your TextFormField is working properly. That's something that took me a long time to learn.
You could add keyboard parameter to specify the keyboard type but without it also it should show the keyboard when you click on the textfield
You need to go settings in the Xcode IDE and look the option ¨I/O¨ there is an option call Toggle Software Keyboard

How to disable onscreen keyboard on startup of view in Flutter?

I started out writing a Flutter app to remotely control some radio stream. I ran into a problem when adding a TextFormField to display the stream's current volume setting. (The reason why I opted for a TextFormField instead of simply Text is that I wanted to use the field for both showing the current setting and letting the user change the current value in one place.)
The problem is the following: When I added the TextFormField (located inside the green bar in the screen shot below, after the text Vol:), I realized that whenever I started this view/page, the onboard keyboard always showed up by default when entering the page.
Instead, I would like the keyboard to only show up when the user clicks inside the TextFormField.
The code for the TextFormField looks as follows:
TextFormField(
onFieldSubmitted: (value){
print("The value entered is : $value");
},
// Define keyboard type
keyboardType: TextInputType.number,
// Make sure user doesn't enter letters or punctuation
inputFormatters: <TextInputFormatter>[WhitelistingTextInputFormatter.digitsOnly],
validator: (val){
return null;
},
autofocus: true,
controller: volTextEditingController,
style: TextStyle(
color: Colors.white,
fontSize: 16,
),
decoration: InputDecoration(
border: InputBorder.none,
),
maxLines: 1,
)
So, I was wondering whether someone knows how to prevent the keyboard from appearing on startup of the shown view/page. Thanks in advance! The full code, if needed, is available on GitGub.
I just figured out that this problem was caused by the setting autofocus: true. So, removing this solves the issue.