The FocusManager constructor was registering global event handlers
on the shared RawKeyboard instance and the global pointer router.
This posed a few problems: (1) there was no way to unregister these
handlers, and (2) instantiating a second FocusManager would overwrite
the existing focus manager's RawKeyboard handler. This was manifesting
in unexpected ways, such as the fact that constructing a second
BuildOwner (for a parallel tree, for instance) was obliterating the
event handler for the main BuildOwner's focus manager, thus messing
with focus.
This change separates those global event registrations into a
dedicated method, registerGlobalHandlers(), and overrides dispose()
to properly unregister those handlers.
This gets away from the extra static map for global key registrations
in favor of the data structures being instance properties of the build
owner. This still allows for semantically-equivalent static access through
the binding (which in turn gives access to the build owner).
This also adds a `BuildOwner.globalKeyCount` getter to get the count
of global keys associated with widgets currently in the tree.
Element.rebuild() and BuildOwner.buildScope() both had code to
manager the `BuildOwner._debugCurrentBuildTarget` state variable.
Unfortunately, only one of the two places was using a try/finally
to ensure that the state variable was restored even if an error
was thrown.
This creates a private method to unify the copy/pasted code.
* Reland "Nnbd widgets (#64672)"
This reverts commit 127e67902e8bbb0dcbfb3351b8fd00f7cbdf0178.
* remove non-nullable enforcement on AsyncSnapshot
* make data param non-nullable for AsyncSnapshot.withData
* make some Text params non-nullable
* migrate widget to nullsafety
* remove double blank line after license
* address review comments in actions.dart
* nullable ObjectKey.value
* use local variable oldElement
* make State.build non-nullable
* make State.context non-nullable
* newline at eof
* make ProxyWidget.child non-nullable
* make _InactiveElements.debugContains non-nullable
* make Element.depth non-nullable
* make ProxyElement.build non-nullable
* make StatefulElement.state non-nullable
* remove 'Notice that'
* avoid cast of list in RenderObjectElement.updateChildren
* make IndexedSlot.value non-nullable
* avoid cast of list in MultiChildRenderObjectElement.mount
* make some WidgetsApp parameters non-nullable
* hitTest take non-nullable position
* make ScrollableState.position non-nullable
* use _pixels instead of pixels
* make ViewportOffset.pixels non-nullable
* make param and return type of IndexedWidgetBuilder non-nullable
* unused_import
* make context param non-nullable for Builder in animated_list.dart
* make ScrollMetrics.viewportDimension non-nullable
* make ScrollMetrics.{min,max}ScrollExtent non-nullable
* make _Location.file non-nullable
* _WidgetForTypeTests.createElement throw UnimplementedError
* update _NullWidget.build error message
* make _ShortcutsState.manager non-nullable
* Fix childCount issues for NNBD
* fix childCount computation on web
* increase max value on js side to compute childCount
* make aspect parameter of dependOnInheritedWidgetOfExactType nullable
* merge has{min,max}ScrollExtent into hasScrollExtents
* update focus_manager.dart
* address review comments in icon.dart
* address review comments in image.dart
* address review comments in routes.dart
* address review comments in scroll_activity.dart
* update doc comments
* make UserScrollNotification.direction non-nullable and required
* rename hasScrollExtents to hasContentDimensions
* unnecessary late
Co-authored-by: Ian Hickson <ian@hixie.ch>