Flutter's `moreOrLessEquals` has a few advantages over `closeTo` from
the `matcher` package:
* It emits the epsilon value in the test result on failure.
* It uses a named parameter for epsilon, which improves readability
at the call site.
* It has a reasonable default for epsilon in cases where something
more specific isn't required.
Using it also has the nice property that it aids in its own discovery
when when people go looking for such functionality in new tests.
This change also includes a couple unrelated whitespace formatting cleanups.
This adds a new navigationMode to the MediaQueryData that indicates how focusable controls should behave under different navigation modes, currently with two modes: NavigationMode.traditional, and NavigationMode.directional.
It may seem like focusing a disabled control is not desirable, but this is useful for user interfaces that use DPAD navigation because if a control gets disabled, losing focus is disruptive to the user, and it is difficult to control where the focus will end up unless it is done explicitly.
This PR adds the linux and windows target platform enum values, along with automatically setting the defaultTargetPlatform to the appropriate value on those platforms.
Fixes#31366
This contains the test changes for adding TargetPlatform.macOS, which was done in #43457.
The main goal of this PR is to enable tests in the material library that are currently running only on iOS to also run on macOS, but only for the tests where that makes sense. For instance, we don't run any of the haptic feedback tests on macOS.
* Update project.pbxproj files to say Flutter rather than Chromium
Also, the templates now have an empty organization so that we don't cause people to give their apps a Flutter copyright.
* Update the copyright notice checker to require a standard notice on all files
* Update copyrights on Dart files. (This was a mechanical commit.)
* Fix weird license headers on Dart files that deviate from our conventions; relicense Shrine.
Some were already marked "The Flutter Authors", not clear why. Their
dates have been normalized. Some were missing the blank line after the
license. Some were randomly different in trivial ways for no apparent
reason (e.g. missing the trailing period).
* Clean up the copyrights in non-Dart files. (Manual edits.)
Also, make sure templates don't have copyrights.
* Fix some more ORGANIZATIONNAMEs
* 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>
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
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
There were four or five different implementations in various tests for sendFakeKeyEvent, which roughly all did the same thing. I was going to add yet another one, and decided that it needed to be generalized and centralized. This replaces those instances with something that just takes a LogicalKeyboardKey so that it's self-documenting, and can be used with multiple platforms.
This adds two functions to widget tester: sendKeyDownEvent and sendKeyUpEvent which simulate key up/down from a physical keyboard. It also adds global functions simulateKeyDownEvent and simulateKeyUpEvent that can be called without a widget tester. All are async functions protected by the async guard.
This changes the behavior of text fields, Material buttons, and Chips so that if they are disabled they lose focus. Before this change, it was possible to disable a control and then use focus traversal to reach it anyhow, and in the case of text fields, enter text into a disabled field.
Fixes#33985
* Moved the default BinaryMessenger instance to ServicesBinding
This reverts commit 821602aef3.
* Added assertion in defaultBinaryMessenger. Also fixed the devicelab tests.
This reverts commit 92ef2b9ce1.
This requires either runApp() or
WidgetsFlutterBinding.ensureInitialized() to have been called before
using any MethodChannels. Plugins broadly rely on MethodChannels and
right now there's no general requirements that they be constructed
within the runApp call, so the ecosystem breakages from this are broader
than originally thought. Reverting for now.
* Deprecates `BinaryMessages` in favor of a default instance of `BinaryMessenger`, called `defaultBinaryMessenger`
* Platform channels use the `defaultBinaryMessenger` for their binaryMessenger default argument.
This implements focus and hover handling for Material buttons. It inserts Focus widgets into the tree in order to allow buttons to be focusable via keyboard traversal (a.k.a. TAB traversal), and Listener widgets into the InkWell to allow the detection of hover states for widgets.
Addresses #11344, #1608, and #13264.
This fixes#32525, because it now marks the compositing bits as needing to be recalculated if the mouse tracker changes its idea of whether or not a mouse is attached.
This bug occurred because the test framework was leaking state from one test to the next (the state about whether a mouse pointer was active), and so even though there was a "passing" test when run in order with the other tests in the file, when the test was run individually (or first), it would have failed and caught the bug.
This adds an assert to make sure that after each test there are no simulated mouse pointers connected, and now calls removePointer in all of the tests where this was a problem.
This implements a DefaultFocusTraversal widget to describe the focus traversal policy for its children, defined by a FocusTraversalPolicy object from which custom policies may be created. Pre-defined policies include widget-order traversal, "reading order" traversal and directional traversal.
This re-lands the Focus changes in #30040. Correctness changes in routes.dart, and removes the automatic requesting of focus on reparent when there is no current focus, which caused undesirable selections.
Addresses #11344, #1608, #13264, and #1678Fixes#30084Fixes#26704
Implements focus traversal for desktop platforms, including re-implementing the existing focus manager and focus tree.
This implements a Focus widget that can be put into a widget tree to allow input focus to be given to a particular part of a widget tree.
It incorporates with the existing FocusScope and FocusNode infrastructure, and has minimal breakage to the API, although FocusScope.reparentIfNeeded is removed, replaced by a call to FocusAttachment.reparent(), so this is a breaking change:
FocusScopeNodes must now be attached to the focus tree using FocusScopeNode.attach, which takes a context and an optional onKey callback, and returns a FocusAttachment that should be kept by the widget that hosts the FocusScopeNode. This is necessary because of the need to make sure that the focus tree reflects the widget hierarchy.
Callers that used to call FocusScope(context).reparentIfNeeded in their build method will call reparent on a FocusAttachment instead, which they will obtain by calling FocusScopeNode.attach in their initState method. Widgets that own FocusNodes will need to call dispose on the focus node in their dispose method.
Addresses #11344, #1608, #13264, and #1678Fixes#30084Fixes#26704
* Disallow cursor from appearing beyond the width of the input.
* Test that verifies the cursor can't exceed the width of the input
* Use constant from editable.dart to explain 1 pixel difference in test
* Fix failing test that tested the case of overflowing spaces
* some space formattings
* always use blocks in if-else if a block is used
* format spaces in for and while
* allow multiline if conditions
* fix missing space
Adds the `minLines` and `expands` parameters for controlling text height. The original PR was reverted, so this one contains a few extra fixes for the tests that were broken.
* Create new TextField attribute to control maxLength behaviour
* Create test case for maxLinesIncrementalHeight
* fix maxLinesIncrementalHeight set method
* fix editable_test.dart
* Just introducing some proposed API additions, renaming to expands
* Pass minLines and expands through to child widgets and validate
* minLines can't be null, and expands can't be true when maxLines is 1
* Implement minLines and maxLines height sizing logic
* Simplify minLines validation logic
* expands parameter proof of concept
* min/max mixup bug fix, and tests work with expands false
* Test expands=true cases, and fix textPainter.height being out of date
* Test all behavior matrix cases
* min/max assertion more strict, can't be equal
* Tests work that were missing expands serialization
* Action sheet tests no longer fail due to rounding error
* TextFieldFocus test no longer mysteriously fails
* TODOs for making expands nullable. Will depend on how Expanded wrapping works
* Expanded growth happens when expanded is true and maxLines is null
* Test Expanded wrapper
* No more overflow when wrapped in Expanded
* Docs improvements
* expands can be null
* Simplify error cases to support existing behavior
* Docs examples and other docs cleanup
* Expansion up to perfectly meet the parent size
* Fix analyze null error
* Fix test after move to nullable expands
* minLines defaults to null
* expands is now exclusively for expanding to parent height and not growth between min and max
* _layout rewritten to handle max height. Need to fix prefix tests and
reenable expands
* Tests for textfield overflowing parent
* layoutLineBox is documented and private
* expands works in new _layout
* _layout return numbers seem to perfectly match original _layout
* inputWidth comment after trying it out and failing tests
* Fix analyze errors
* WIP prefix/suffix do affect height
* Prefix/suffix and icons affect height, tests pass, but I'm still visually verifying identical to original
* Tall prefix test that verifies pixel perfect layout
* Fix overflowing edge case and test it
* Clean up comments, old code, and todos
* Changing _expands causes relayout. Wasnt able to figure out how to test though...
* Clean up code review comments
* Fix misalignment when tall prefix and border, and clean up related test
* Simple code review cleanup
* Bring back inputWidth to _layout method
* Fix rounding errors showing up in mac tests
* Fix flake by reordering tests. Without this, the dreaded intrinsicwidth flake is reproducible 50% of the time on my machine.
* Fix more rounding error mac tests
* add trailing commas on list/map/parameters
* add trailing commas on Invocation with nb of arg>1
* add commas for widget containing widgets
* add trailing commas if instantiation contains trailing comma
* revert bad change