1. 25 Oct, 2022 2 commits
  2. 24 Jun, 2022 1 commit
  3. 14 Apr, 2022 1 commit
  4. 10 Jan, 2022 1 commit
  5. 05 Nov, 2021 1 commit
  6. 08 Oct, 2021 3 commits
  7. 30 Sep, 2021 1 commit
    • Greg Spencer's avatar
      Add external focus node constructor to Focus widget (#90843) · d94c18d2
      Greg Spencer authored
      I've added a Focus.withExternalFocusNode constructor to the Focus widget (and the FocusScope widget) that makes it explicit that the widget's attributes won't affect the settings of the given focus node.
      
      This is to help address #83023, which is a snag in the API that people run into occasionally.
      
      This should help make it explicit when you want the widget attributes to take precedence, and when you don't.
      d94c18d2
  8. 14 May, 2021 1 commit
  9. 28 Apr, 2021 1 commit
  10. 14 Apr, 2021 1 commit
  11. 13 Apr, 2021 1 commit
  12. 12 Apr, 2021 1 commit
  13. 04 Mar, 2021 1 commit
  14. 12 Feb, 2021 1 commit
  15. 29 Oct, 2020 1 commit
  16. 12 Oct, 2020 1 commit
  17. 23 Jul, 2020 1 commit
    • Greg Spencer's avatar
      Fix `ExcludeFocus` so it won't refocus a sibling of the focused node. (#61756) · cac22cdb
      Greg Spencer authored
      This changes FocusNode.descendantsAreFocusable so that it doesn't allow the enclosing scope to re-focus a node that is a descendant of the node with descendantsAreFocusable set to false.
      
      Because of the order in which the internal state for descendantsAreFocusable was being set, setting it to false was causing a sibling node to be focused when descendantsAreFocusable of the parent was set to false, even though it shouldn't have been focusable, because the enclosing scope would search for a candidate to be focused before the internal state was set to false.
      
      Instead of looping over the children and telling them all to unfocus (and select the previously focused node), this unfocuses the node that has descendantsAreFocusable set to false, with the disposition UnfocusDisposition.previouslyFocusedChild, so that its enclosing scope will look for a previously focused child that isn't part of the subtree being excluded.
      
      This affects how the ExcludeFocus widget behaves when turning on exclude.
      cac22cdb
  18. 11 Jun, 2020 1 commit
  19. 08 May, 2020 1 commit
  20. 01 May, 2020 1 commit
    • Greg Spencer's avatar
      Add `ExcludeFocus` widget, and a way to prevent focusability for a subtree. (#55756) · fdc4d21b
      Greg Spencer authored
      This adds an ExcludeFocus widget that prevents widgets in a subtree from having or obtaining focus. It also adds the ability for a FocusNode to conditionally prevent its children from being focusable when it isn't focusable (i.e. when canRequestFocus is false).
      
      It does this by adding an descendantsAreFocusable attribute to the FocusNode, which, when false, prevents the descendants of the node from being focusable (and removes focus from them if they are currently focused).
      fdc4d21b
  21. 27 Feb, 2020 1 commit
    • Greg Spencer's avatar
      Change Focus.unfocus to take a disposition for where the focus… (#50831) · d4226566
      Greg Spencer authored
      When Focus.unfocus is called, the caller usually just thinks about wanting to remove focus from the node, but really, unfocus is a request to automatically pass the focus to another (hopefully useful) node.
      
      This PR removes the focusPrevious flag from unfocus, and replaces it with a disposition enum that indicates where the focus should go from here.
      
      The other value of the UnfocusDisposition enum is UnfocusDisposition.scope.
      
      UnfocusDisposition.previouslyFocusedChild is closest to what focusPrevious used to do: focus the nearest enclosing scope and use its focusedChild field to walk down the tree, finding the leaf focusedChild. This PR modifies it slightly so that it walks up to the nearest focusable enclosing scope before trying to focus the children. This change addresses #48903
      
      A new mode: UnfocusDisposition.scope will focus the nearest focusable enclosing scope of this node without trying to use the FocusScopeNode.focusedChild value to descend to the leaf focused child. This is useful as a default for both text field finalization and for what happens when canRequestFocus is set to false. It allows the scope to stay focused so that nextFocus/previousFocus still work as expected, but removes the focus from primary focus.
      
      In addition to those changes, unfocus called on a FocuScope that wasn't the primary focus used to unfocus the primary focus instead. I removed that behavior, since it was buggy: if the primary focus was inside of a child scope, and you called unfocus on the parent scope, then the child scope could have focused another of its children instead, leaving the scope that you called unfocus on with hasFocus returning true still. If you want to remove the focus from the primary focus instead of the scope, that's easy enough to do: just call primaryFocus.unfocus().
      
      Fixes #48903
      d4226566
  22. 13 Feb, 2020 1 commit
    • Greg Spencer's avatar
      Reland: Add OrderedFocusTraversalPolicy and FocusTraversalGrou… (#50672) · d57d4935
      Greg Spencer authored
      This re-lands #49235 with the addition of includeSemantics flag on the Focus widget so that the FocusTraversalGroup can create a Focus widget without affecting the semantics tree.
      
      The FocusTraversalGroup uses the Focus widget to create a grouping of descendants for traversal, but doesn't actually participate in focus (canRequestFocus is always false), so we don't want it to add a Semantics widget in that case, since that can cause semantics changes. The canRequestFocus attribute can also be used when a widget is disabled, so we do sometimes want to include Semantics even if that is false, but not in the case where it is always false, as for FocusTraversalGroup.
      
      - Added a test to make sure that FocusTraversalGroup doesn't add any semantics information.
      d57d4935
  23. 12 Feb, 2020 1 commit
  24. 11 Feb, 2020 1 commit
    • Greg Spencer's avatar
      Add OrderedFocusTraversalPolicy and FocusTraversalGroup to all… (#49235) · 8ef5e2f0
      Greg Spencer authored
      This change adds a way to provide explicit focus order for a part of the widget tree.
      
      It adds FocusTraversalPolicyGroup, which in many ways is similar to DefaultFocusTraversal, except that it groups a widget subtree together so that those nodes are traversed as a group. DefaultFocusTraversal doesn't work as one would expect: If there is more than one DefaultFocusTraversal inside of a focus scope, the policy can change depending on which node was asked to move "next", which can cause unexpected behavior. The new grouping mechanism doesn't have that problem. I deprecate DefaultFocusTraversal in this PR.
      
      It also adds OrderedFocusTraversalPolicy, which is a policy that can be supplied to FocusTraversalPolicyGroup to set the policy for a sub-tree. It looks for FocusTraversalOrder inherited widgets, which use a FocusOrder to do the sorting. FocusOrder has two subclasses: NumericalFocusOrder (which sorts based on a double), and LexicalFocusOrder, which sorts based on a String.
      
      As part of doing this, I refactored the way FocusTraversalPolicy is implemented so that it has more default implementation methods, and exposes a new protected member: sortDescendants, which makes it easier for developers to make their own policy subclasses: they only need to implement sortDescendants to get a new ordering behavior, but can also still override any of the default implementation behaviors if they need different behavior.
      
      I was able to do this without breaking the API (AFAICT).
      8ef5e2f0
  25. 13 Jan, 2020 1 commit
    • Greg Spencer's avatar
      Allow requestFocus on an unattached FocusNode to create a deferred focus request (#48589) · 6495d377
      Greg Spencer authored
      This changes the behavior of requestFocus when it is called on a FocusNode that does not yet have a parent, so that it defers requesting focus until it receives a parent. Before this change, calling requestFocus before it had a parent was a no-op.
      
      This allows scenarios where a widget is newly added and wishes to immediately request the focus. Previously, it was very hard to make that work because requesting focus before the widget's focus node had a parent was ignored, so the developer had to wait until two frames later to request focus (one for the widget's node to be added to the focus tree, and one to request the focus).
      
      Now, in order to have a widget be focused when initially added, you just need to call requestFocus on its node when you create it, and as soon as it is added, it will automatically request focus.
      
      This is different from the autofocus attribute on the Focus widget, because it unconditionally requests focus when added (autofocus will only request focus if nothing else in the scope has focus).
      6495d377
  26. 05 Dec, 2019 1 commit
    • Greg Spencer's avatar
      Fixes Focus and FocusScope's assignment of canRequestFocus. (#46168) · e3005e69
      Greg Spencer authored
      This fixes an issue where lines like this:
      
          focusNode.canRequestFocus = widget.canRequestFocus ?? focusNode.canRequestFocus;
      
      Were causing the canRequestFocus bit to copy the status of the enclosing scope, since canRequestFocus also looks to the enclosing scope to decide if it can focus.
      e3005e69
  27. 03 Dec, 2019 1 commit
    • Greg Spencer's avatar
      Clean up some things I noticed while doing another change (#45658) · 37f86c31
      Greg Spencer authored
      This fixes some minor things I noticed while doing another change.
      
      - Uncomments an old test that wants to be run, but can't be, and marked it as "skipped", so that the code won't rot anymore.
      - Added the focus state to the short string version of a FocusNode
      - Added a missing piece of information to findAncestorWidgetOfExactType
      37f86c31
  28. 27 Nov, 2019 1 commit
    • Ian Hickson's avatar
      License update (#45373) · 449f4a66
      Ian Hickson authored
      * 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
      449f4a66
  29. 01 Nov, 2019 1 commit
    • Greg Spencer's avatar
      Add convenience accessor for primaryFocus (#43859) · 3a30722f
      Greg Spencer authored
      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.
      3a30722f
  30. 30 Oct, 2019 1 commit
  31. 28 Oct, 2019 2 commits
  32. 23 Oct, 2019 2 commits
  33. 15 Oct, 2019 1 commit
    • Greg Spencer's avatar
      Optimize focus operations by caching descendants and ancestors. (#42683) · 134ac429
      Greg Spencer authored
      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
      134ac429
  34. 14 Oct, 2019 1 commit
    • Greg Spencer's avatar
      Fix route focusing and autofocus when reparenting focus nodes. (#42554) · e2c5fd6c
      Greg Spencer authored
      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.
      e2c5fd6c
  35. 09 Oct, 2019 1 commit
    • Greg Spencer's avatar
      Enables setting of semantics focused and focusable attributes within Focus widgets. (#41814) · 89d6c8d9
      Greg Spencer authored
      This adds a Semantics node to the Focus and FocusScope widgets, setting the focused and focusable attributes so that the accessibility subsystem can be told when a control has the input focus.
      
      Includes an engine roll to flutter/engine@77252d2, and the following 8 engine changes:
      
      flutter/engine@77252d2 Greg Spencer Add missing focusable testing info (flutter/engine#13013)
      flutter/engine@0e42a29 skia-flutter-.. Roll src/third_party/skia 54548626a977..e27a503a0a21 (1 commits) (flutter/engine#13024)
      flutter/engine@6b56ed7 gaaclarke Refactor: FlutterDartProject (flutter/engine#13006)
      flutter/engine@393480c skia-flutter-.. Roll src/third_party/skia 77dde599c98a..54548626a977 (1 commits) (flutter/engine#13023)
      flutter/engine@080b89d skia-flutter-.. Roll src/third_party/skia 2b1a25a4d324..77dde599c98a (1 commits) (flutter/engine#13021)
      flutter/engine@90b0f30 Ben Konyi Roll src/third_party/dart f4a72bfc64..bb04f145b2 (18 commits) (flutter/engine#13020)
      flutter/engine@049fb89 skia-flutter-.. Roll fuchsia/sdk/core/linux-amd64 from q_uYX... to cknsi... (flutter/engine#13019)
      flutter/engine@6925b2a skia-flutter-.. Roll fuchsia/sdk/core/mac-amd64 from wuAtw... to u0JpE... (flutter/engine#13018)
      
      Related Issues
      Addresses #40101
      
      Landing on red in order to fix the build: it's red because of the needed engine roll.
      89d6c8d9