Currently, we listen to keyboard events to find out which keys should be represented in RawKeyboard.instance.keysPressed, but that's not sufficient to represent the physical state of the keys, since modifier keys could have been pressed when the overall app did not have keyboard focus (especially on desktop platforms).
This PR synchronizes the list of modifier keys in keysPressed with the modifier key flags that are present in the raw key event so that they can be relied upon to represent the current state of the keyboard. When synchronizing these states, we don't send any new key events, since they didn't happen when the app had keyboard focus, but if you ask "is this key down", we'll give the right answer
This missed some plugins that _do_ support the v1 embedding
(shared_preferences as one known case) so caused unexpected breakages.
This reverts commit b94c1a41ca.
* Adding handling of TextInputClient.onConnectionClosed messages handling to Framework
* Adding more test cases for closing connection to editable_text_test
* fixing analyze error.
* Fixing analyze error in the test file
* Fixing comments on the new method
* Adding more closing connection examples.
* Indentation change
* Remove auto-add white space
* Changing the oncloseconnection behaviour to stop editing. Updating the tests
* Addressing PR comments. Added explicit log for method channnels to the tests. Added comments to the interfaces.
* add more documentation
This adds accessors for WidgetsBinding.instance.focusManager and WidgetsBinding.instance.focusManager.primaryFocus so that they can be more easily found in IDEs and accessed.
This adds a top level getter for WidgetsBinding.instance.focusManager.primaryFocus called primaryFocus, and a static accessor FocusManager.instance that returns WidgetsBinding.instance.focusManager.
Makes sure that disabled InkWell/InkResponse and widgets that use them don't allow themselves to be focused.
ListTile, PopupMenu, and Stepper were not setting canRequestFocus properly on the InkWell, and InkWell was allowing focus even if it was disabled (it was basically just relying on the containing widget to set canRequestFocus properly). Now InkWell must both be enabled (have an onTap or similar) and have canRequestFocus set to true.
This fixes https://github.com/flutter/flutter/issues/39277
The following tests cover this change:
- packages/flutter/test/foundation/service_extensions_test.dart
- packages/flutter/test/scheduler/scheduler_test.dart
Check for a binary callback first since a function with an optional
second argument will match both typedefs.
Remove documentation around a synchronous error following some other
error or value - a synchronous error can never follow a value or an
asynchronous error. If there is a synchronous error it will _always_ be
the first thing to happen.
Add a test for a unary error handler and an error handler with an
optional stack trace argument.
The environment variable for all desktop platforms is currently
ENABLE_FLUTTER_DESKTOP to allow backward compatibility with existing
workflows. However, this is actually causing issues since 'flutter
config' provides a better experience (most importantly, IDEs will work
correctly, which is generally not the case with the environemnt
variable). Currently people following old (third-patry) instructions
don't realize that they are missing available functionality, so aren't
looking for the current instructions.
In adddition, this will be confusing as different platform graduate to
channels other than master at different times.
To resolve both issues, the environment variable fallback is now
separate for each desktop platform, and follows a naming scheme
consistent with the web environment variable.
This re-lands the change that adds focus nodes, hover, and shortcuts to switches, checkboxes, and radio buttons. (#43213), with fixes for the web tests that weren't enabled in the master that it was synced to when I first landed it.
This is to account for the flutter_runner migration.
fxb/fl-250 has more context. This change specifically uses
the build rules that were added as a part of: fxr/333681
Drag from the right is no more
Longpress is now only 100ms instead of 500
Added optional duration field to longpressgesturerecognizer
Added controller field to material scrollbar api
Haptic feedback only triggers when scrollbar is fully expanded
Added haptic feedback when releasing the scrollbar after dragging it
* Wrap alert dialog title and content in single child scroll view
* Scrollable alert dialog title and content tests
* Remove unnecessary comment
* Fix mainAxisSize and crossAxisAlignment issue
* Add structured errors in Animations, TabView, ChangeNotifier
* Add structured error on MaterialPageRoute, BoxBorder, DecorationImagePainter, TextSpan
* Add structured errors in Debug
* Fix test errors
* Add structured errors in Scaffold and Stepper
* Add structured errors in part of Rendering Layer
* Fix failing test due to FloatingPoint precision
* Fix failing tests due to precision error and not using final
* Fix failing test due to floating precision error with RegEx instead
* Add structured error in CustomLayout and increase test coverage
* Add structured error & its test in ListBody
* Add structured error in ProxyBox and increase test coverage
* Add structured error message in Viewport
* Fix styles and add more assertions on ErrorHint and DiagnosticProperty
* Add structured error in scheduler/binding and scheduler/ticker
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Add structured error in AssetBundle and TextInput
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Add structured errors in several widgets #1
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Remove unused import
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Add assertions on hint messages
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Fix catch spacing
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Add structured error in several widgets part 2 and increase code coverage
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Add structured error in flutter_test/widget_tester
* Fix floating precision accuracy by using RegExp
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Remove todo to add tests in Scaffold showBottomSheet
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Fix reviews by indenting lines and fixing the assertion orders
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Fix failing tests due to renaming class
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Try skipping the NetworkBundleTest
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Remove leading space in material/debug error hint
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Fix DropdownButton disabledHint behavior
* Fix hint behavior when selectedItemBuilder is null
* Improve variable names, some formatting updates
* Create _DropdownMenuItemContainer widget
* Improve API docs to be consistent with hint/disabledHint actual behavior
This re-lands the change that adds focus nodes, hover, and shortcuts to switches, checkboxes, and radio buttons. (#43213)
No changes from original, except for finding the right RenderBox in dev/integration_tests/android_semantics_testing/test_driver/main_test.dart.
* Add repeatCount to RawKeyEventDataAndroid
Adds a new field to RawKeyEventDataAndroid and sets it to the value
passed from the engine. It is the value returned by
KeyEvent.getRepeatCount(). This allows us to differentiate between
events generated by a new keypress and repeated events when a key is
held down.
* Add test for RawKeyEventDataAndroid.repeatCount
In order to enable keyboard navigation to more controls, I've added focus nodes to switches, checkboxes, and radio buttons. In addition, this change enables mouse hover over these controls.
- Added tests for focus, hover, and shortcut activation for Checkbox, Radio, and Switch.
Empirical measurements indicate on the network file system we use
internally, using `FileStat.stat` on thousands of files is much
faster than using `FileStat.statSync`. (It can be slower for files
on a local SSD, however.)
Add a flag to `ProjectFileInvalidator.findInvalidated` to let it
use `FileStat.stat` instead of `FileStat.statSync` when scanning for
modified files. This can be enabled by overriding `HotRunnerConfig`.
I considered creating a separate, asynchronous version of
`findInvalidated`, but that led to more code duplication than I
liked, and it would be harder to avoid drift between the versions.
This PR adds a new property on RawKeyEventDataAndroid to hold the deviceId from which that event was generated. The deviceId is been sent from the engine on the changes from this PR: flutter/engine#12958
With this, we will be able to identify from where the event came from, adding the ability to support local multiplayer games, with multiple gamepads.
This adds a canRequestFocus and skipTraversal argument to FocusScope and FocusScopeNode, so that a scope can prevent being traversed.
This allows a fix for a problem in the gallery where the focus while traversing the list of items would sometimes appear to disappear, since it would be focusing things that were in the backdrop that were part of the tree, but were not visible.
Related Issues
Fixes#42955
This adds a Focus node to the DropdownButton widget, allowing it to receive keyboard focus, and to show a focus highlight. In addition, I added the ability to activate the dropdown using the "enter" key binding (which is bound to ActivateAction in the WidgetsApp).
Related Issues
Fixes#42646Fixes#43008Fixes#42511
Flutter tool's service client library tries to "upgrade" sub-components of service responses with higher level model objects. It does this for all members of the response, rather than only those documented in the version it targets, and it errors out when encountering a new type. This causes it to fail when a new field is introduced with a new typed. Clients are required to ignore this.
This re-implements keyboard text selection so that it will work on platforms other than Android (e.g. macOS, Linux, etc.).
Also, fixed a number of bugs in editing selection via a hardware keyboard (unable to select backwards, incorrect conversion to ASCII when cutting to clipboard, lack of support for CTRL-SHIFT-ARROW word selection, etc.).
Did not address the keyboard locale issues that remain, or add platform specific switches for the bindings. All that will need some more design work before implementing them.
Related Issues
Fixes#31951
In #42533, I disabled the up/down arrows for focus navigation in text fields, but we thought of a better way to do it, so this is that better way.
This change reverts the other change, and instead it tests the context of the node in the action to see if it's an EditableText node. If so, then it doesn't do the navigation action.
The _computeChildren[Width/Height]With[Min/Max]Intrinsics methods in
RenderParagraph overwrite the text painter's placeholder dimensions
in order to compute potential widths and heights for the paragraph.
The placeholder dimensions should be restored to the values computed by
_layoutChildren before painting the text.
This optimizes certain paths in the FocusManager, FocusNode, and FocusScopeNode classes in order to fix a regression in stock_animation_open_first_frame_average when I added more focus nodes to the tree to do focus traversal.
Mainly I removed some remaining sync* iterators, and also started caching the computation of descendants and ancestors, since those are iterated over fairly often.
This improves stock_animation_open_first_frame_average by about 2.8% overall (so about half of a 4.9% regression, both averaged over 10 runs).
Addresses #42564
This disables the arrow key focus navigation for text fields. This was non-standard behavior for text fields, although it remains useful for other kinds of controls.
Fixes#42259
This fixes a problem with reparenting of focus nodes where it would remove the node from the scope's focused children when reparented, even if it was being reparented to another place under the same scope. This only occurred if the scope in question didn't have focus.
This caused nodes to not get autofocused when they were a child of another node within the scope, and were reparented, and then the scope was given focus (as when a route is pushed).
This keeps the node in the scope's child list where it was if the node is reparented under a parent within the same scope.
- Added a test that tries to autofocus a TextField when the route is pushed and there is another
FocusNode above the text field. This was how this was first noticed: the autofocus got ignored in
this configuration.
- Added a test to focus_manager_test that tests for the specific case of reparenting a node when
it's in the focused children of the scope.
* Updated the BottomAppBar to use elevation overlays when a dark theme is used.
* Moved the code for calculating the overlay color to a new utility
ElevationOverlay class and made it private by not including in the material package.
* Allow showModalBottomSheet to present bottom sheet that is not dismissible by tapping on the scrim
* Add guards, improve styling and tests for BottomSheet
This changes the DropDownButton so that instead of dismissing itself when any metrics change occurs, it only dismisses itself when the orientation changes.
This gets around the fact that we can't currently have a dropdown and a text field on the same page because the keyboard disappearing when the dropdown gets focus causes a metrics change, and the dropdown immediately disappears when activated.
It still will cause the keyboard to jump up and down between controls, but that's a larger issue. At least now we can use the two together again.