* 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
* Include caret gaps in position calculation to avoid descender cutoff
* Calculate caret offset instead of exposing it
* Test that textfields scroll vertically by full line height
* Only add offset to end of caret to avoid going above 0.0
* Fix and test horizontal vs. vertical scrolling
* CR: docs and top caret offset logic
* Take max instead of assuming caretRect.top is always a full line down
* Always subtract caretOffset from caretTop since caretRect.top can be negative
* Allow a widget to be specified for the textfield count, and allow no count at all
* Test all possible states for counter and counterText
* Docs for counter
* counter is a function that generates a widget
* Tests use counter as function
* Fix analyze error in docs
* InputDecoration has counter widget, TextField has buildCounter function
* InputDecorator tests expect counter to be widget again and include
buildCounter
* counter widget example that might actually fit
* Clarify accessiblity concerns in docs
* Include isFocused param for accessibility
* Fix analyze error
* Improve docs per code review
* Rearrange getEffectiveDecoration a bit for clarity
* Fix analyze error about hashValues params
* Clean up docs and redundant code per code review
* Code review doc improvement
* Automatically wrap buildCounter widget in a Semantics widget for accessibility
* the onStart callback will report the location of the pointer where it wins the gesture arena by default instead of the pointer down location. Fixes all tests related to changing this default value.
* Adds start behavior option to the drag gesture recognizer and makes it the default option when a drag gesture recognizer is created. Also fixes all the tests to work correctly with the new default behavior.
* Revert "Add imports section to sample code templates, and more docs. (#25184)"
This reverts commit 95b0124785.
* Revert "Use stderr instead of stdout to contain errors in flutter attach test (#25305)"
This reverts commit 2b819dd257.
* Revert "Allow detection of taps on TabBar (#23919)"
This reverts commit 01694ab62d.
* Revert "a549981da Roll src/third_party/skia a69b10312977..5eb29448dfbd (1 commits) (flutter/engine#7211) (#25333)"
This reverts commit a37099f3b1.
* Revert "Revert "obscureText and enableInteractiveSelection defaults (#24527)" (#25335)"
This reverts commit c5457068df.
* Password fields are no longer selectable nor copiable
* obscureText true defaults to disabling selection
* Tests and comments for selectable text field
* Improve selection docs
* Refactor so that all enableInteractiveSelection params are null by default, delegate to selectionEnabled
* Fix selection param macros
* Merge TextField style with global style so that style changes don't override unspecified fields
* Test that a style param is merged with the theme
* Test a few more style properties
* Analysis fix
Make it possible to disable TextField's default handlers for tap and long press. If enableInteractiveSelection is false then taps no longer move the text caret and long-press no longer selects text and shows the cut/copy/paste menu. Accessibility is similarly limited.
For G3 Roll:
* Revert "MaterialButton must honor its minWidth and height parameters (#22919)"
This reverts commit a02332335a.
* Revert "Update uses of ButtonTheme.bar: pass along the current Theme's colorScheme (#22827)"
This reverts commit 655bf6a290.
* Revert "ButtonTheme.of().colorScheme defers to Theme (#22880)"
This reverts commit a590940e45.
* Revert "Bring TextTheme into alignment with the current Material spec (#22330)"
This reverts commit 8bfb4b3ee5.
* Revert "Added ColorScheme, updated ThemeData, ButtonTheme, material buttons (#22013)"
This reverts commit eea3465ae7.
* Manual adjustments to fix reversion issues.
* Make CupertinoApp and MaterialApp both use WidgetsApp for Navigator
* Make CupertinoApp and MaterialApp const constructors
* Make WidgetsApp routes aware
* Update tests
* Revert "Revert "Add RichText support to find.text" (#22046)"
This reverts commit 8e70421913.
* Revert "Implement Double Tap Handling in TextField and Editable (#21264)"
This reverts commit 02e87334dd.
Thanks @NikoYuwono for getting this working! We appreciate your help!
* Implement Double Tap Handling in TextField and Editable
* Fix test broken by the change and add test for double tap
* Fix affected tests
* Remove unnecessary new
* Fix test
* added shortcuts and delete functionality
* added first test
* afew chnages
* a few changes
* hope this works
* small change
* small changes
* fixed nits
* final changes:
* fixed initializing formals
* update comment
* minor change:
* added line
* final changes
* random change
* changed function to void
* one more
* removed line
* dis betta work
* final change
* actual final chnge
* added shortcuts and delete functionality
* added first test
* afew chnages
* a few changes
* hope this works
* small change
* small changes
* fixed nits
* final changes:
* fixed initializing formals
* update comment
* minor change:
* added line
* final changes
* added keyboard functionatliy to android builds
* Added tests
* almost ready for review
* ready for review
* Fixes
* final comments
* final commit
* removing raw keyboard changes
* removing raw keyboard changes
* removing raw keyboard changes
* actual last commit
* fixed the imports
* a few more changes
* A few more changes
* a few changes
* Final changes
* Final changes2
* final actual commit for real
* final actual commit for real2
* final actual commit for real3
* final actual commit for real4
* final
* final 2
* f
* f2
* fin
* fin 2
* fin3
* fin4
* fixed segmented control golden test
* fixed segmented control golden test
* made the comments more explanatory
* changed comment, wrapped tests with if statements so they only run on MacOS
* changed formatting
* added width and radius fields to TextField; to do: tests and Material defaults
* weak warnings
* added tests
* added default cursor width; changed default EditableText width
* only run golden file tests on linux
* changed goldens version
* actually changed goldens.version
* style changes
* small fixes
* added default material cursor color
* changed goldens.version
* changed goldens version again
* changed goldens.version again (3)
* added todo
* deleted whitespace
* fixed segmented control golden test
* fixed segmented control golden test
* added cursorWidth, cursorRadius
* added default value for cursorWidth based on Apple specs
* test default cursorWidth
* removed cursorHeight stuff
* added functionality to keep cursor from blinking
* cursor width and radius is configurable + tests
* changed goldens repo version in goldens.version
* working version of configurable cursor (erased debugKeepCursorOn)
* minor changes
* docs
* changed textfield test that was failing due to new default cursorwidth
* added default value of cursorwidth in RenderEditable
* only run golden file tests on Mac
* cursor tests
* the tests are actually there now
* weak warning fixed
* switching to Linux
* changed default cursorWidth: 2.0 -> 1.0
* assorted changes, including changing text field test
* re-paint -> re-layout when changing cursorWidth
* Use RenderAnimatedOpacity within AnimatedOpacity widget (#15466)
* Fixed minor bug in RenderAnimatedOpacity
* Updated protected API for ImplicitlyAnimatedWidget
New a11y traversal:
- sort direct sibling SemanticsNodes only
- use new sorting algorithm
- implement RTL
- test semantics in traversal order by default
- add AppBar traversal test
- breaking: remove nextNodeId/previousNodeId from the framework
- breaking: remove DebugSemanticsDumpOrder.geometricOrder
* a11y: remove SemanticsSortOrder; sort locally only; semanticsOwner post-test check
* update accessibility test framework
- default nextNodeId/previousNodeId to -1
- stop treating null as opt-out from value testing
- add `id`, `TestSemantics.root`, and `tags` to the suggested code in the TestSemantics failure message
- fix a small bug with raw string escaping
- update all tests accordingly
* fix sortKey doc
* prefer const over final
This fixes the assumption that InputDecorator had where it expected baseStyle to be a complete style. Now it merges the baseStyle with the subhead style instead of substituting it entirely.
This fixes#12832.
This adds an optional character counter and maxLength parameter to the TextField, as described in the Material Design Spec.
The counter text and style in the input decorator may be specified, but will default to the "right thing" if not specified, where the "right thing" is a counter that looks like "3 / 10" (if there are three characters entered into a field where maxLength is set to 10).
To limit the number of characters entered, I created a LengthLimitingTextFormatter that will limit the number of characters (Unicode runes) in the input, which can be used independently. The formatter is applied after the other formatters supplied (if any). Even if there is no decorator, the text field will limit the number of characters input if maxLength is set.
If maxLengthEnforced is set to false (it defaults to true), then the max length will not be enforced. In that case, if the text exceeds the length, then the counter will turn red, and it will make the divider turn red.
* Theme provides all TextStyle properties
* match field declaration order in the test
* Theme.of returns text style with inherit == false
* change TextStyle.inherit logic; docs
* add TextStyle.debugLabel
* address comments
* add debug labels to Typography text styles
Correctly handle the case where the TextEditingController associated
with a TextField is set to null. Due to a typo (= vs ==), previously
this was a no-op and the existing TextEditingController was retained,
rather than copied.
* Introduce a Directionality inherited widget which sets the ambient LTR vs RTL mode (defaulting to null, which means you cannot use directionality-influenced values).
* Make it possible to configure Padding (including Container.padding and Container.margin) using a directionality-agnostic EdgeInsets variant.
* Provide textDirection and verticalDirection controls on Row and Column to make them RTL-aware.
* Introduce a variant of FractionalOffset based on the EdgeInsets variant. Not yet actually used.
* Fix all the tests that depended on Row defaulting to LTR.
Introduce CompositedTransformTarget and CompositedTransformFollower
widgets, corresponding render objects, and corresponding layers.
Adjust the way text fields work to use this.
Various changes I needed to debug the issues that came up.
* Add a text formatter interface used by EditingText. Provide some default implementations.
* self nits
* Handle -1 selection offsets
* review notes
* simplify regular expression
* Add whitelisting formatters. Use a custom phone number formatter in text demo.
* review notes
* not being able to addAll(null) is pretty annoying
* review notes
* partial tests
* Add tests
* didn’t end up needing mockito
* move to services
* Manually fix every use of Point.x and Point.y
Some of these were moved to dx/dy, but not all.
* Manually convert uses of the old gradient API
* Remove old reference to Point.
* Mechanical changes
I applied the following at the root of the Flutter repository:
git ls-files -z | xargs -0 sed -i 's/\bPoint[.]origin\b/Offset.zero/g'
git ls-files -z | xargs -0 sed -i 's/\bPoint[.]lerp\b/Offset.lerp/g'
git ls-files -z | xargs -0 sed -i 's/\bnew Point\b/new Offset/g'
git ls-files -z | xargs -0 sed -i 's/\bconst Point\b/const Offset/g'
git ls-files -z | xargs -0 sed -i 's/\bstatic Point /static Offset /g'
git ls-files -z | xargs -0 sed -i 's/\bfinal Point /final Offset /g'
git ls-files -z | xargs -0 sed -i 's/^\( *\)Point /\1Offset /g'
git ls-files -z | xargs -0 sed -i 's/ui[.]Point\b/ui.Offset/g'
git ls-files -z | xargs -0 sed -i 's/(Point\b/(Offset/g'
git ls-files -z | xargs -0 sed -i 's/\([[{,]\) Point\b/\1 Offset/g'
git ls-files -z | xargs -0 sed -i 's/@required Point\b/@required Offset/g'
git ls-files -z | xargs -0 sed -i 's/<Point>/<Offset>/g'
git ls-files -z | xargs -0 sed -i 's/[.]toOffset()//g'
git ls-files -z | xargs -0 sed -i 's/[.]toPoint()//g'
git ls-files -z | xargs -0 sed -i 's/\bshow Point, /show /g'
git ls-files -z | xargs -0 sed -i 's/\bshow Point;/show Offset;/g'
* Mechanical changes - dartdocs
I applied the following at the root of the Flutter repository:
git ls-files -z | xargs -0 sed -i 's/\ba \[Point\]/an [Offset]/g'
git ls-files -z | xargs -0 sed -i 's/\[Point\]/[Offset]/g'
* Further improvements and a test
* Fix minor errors from rebasing...
* Roll engine
* Fix tests to use Ahem, and helpful changes around that
- Fix fonts that had metric-specific behaviours.
- LiveTestWidgetsFlutterBinding.allowAllFrames has been renamed
to LiveTestWidgetsFlutterBinding.framePolicy.
- LiveTestWidgetsFlutterBinding now defaults to using a frame policy
that pumps slightly more frames, to animate the pointer crosshairs.
- Added "flutter run --use-test-fonts" to enable Ahem on devices.
- Changed how idle() works to be more effective in live mode.
- Display the test name in live mode (unless ahem fonts are enabled).
- Added a toString to TextSelectionPoint.
- Style nit fixes.
* Roll engine to get Ahem changes.
* Update tests for dartdoc changes.
* Fix flutter_tools tests
Fixes a bug where tapping in the text under edit moved the cursor but
did not push the updated selection to the engine.
Adds a test for caret position updates.
We should always use the maxWidth from the incomming constraints to size the
text inside the editable because the EditableText itself always expands to fill
its width.
Also, make sure InputDecoration always expands horizontially (even when there's
no icon) for consistency.
Fixes#9149
After this patch, there are three major text input widgets:
* EditableText. This widget is a low-level editing control that
interacts with the IME and displays a blinking cursor.
* TextField. This widget is a Material Design text field, with all the
bells and whistles. It is highly configurable and can be reduced down
to a fairly simple control by setting its `decoration` property to
null.
* TextFormField. This widget is a FormField that wraps a TextField.
This patch also replaces the InputValue data model for these widgets
with a Listenable TextEditingController, which is much more flexible.
Fixes#7031