• Greg Spencer's avatar
    Fix Focus.of to not find FocusScope nodes. (#32826) · 3c16cf6a
    Greg Spencer authored
    Until this change, Focus.of would return a FocusScopeNode if it found a FocusScope widget. This isn't really all that useful, and can easily lead to bad situations where many widgets think that the scope they are in (or the root scope!) is their indication of being focused.
    
    This changes Focus.of to throw an exception if it doesn't find a Focus widget before reaching the nearest FocusScope widget, or the root of the widget hierarchy.
    
    It also adds a nullOk optional bool to Focus.of so that if a caller expects to not find a Focus widget, it can deal with that as it sees fit. I modified InkWell to use this new behavior.
    
    This fixes an unreported issue that widgets using an InkWell will be drawn as focused the first time they are visited.
    3c16cf6a
focus_manager.dart 42.4 KB