Fix FocusManager constructor (#75894)
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 commit is contained in:
@@ -33,7 +33,6 @@ class Rectangle extends StatelessWidget {
|
||||
|
||||
double? value;
|
||||
RenderObjectToWidgetElement<RenderBox>? element;
|
||||
BuildOwner owner = BuildOwner();
|
||||
void attachWidgetTreeToRenderTree(RenderProxyBox container) {
|
||||
element = RenderObjectToWidgetAdapter<RenderBox>(
|
||||
container: container,
|
||||
@@ -74,7 +73,7 @@ void attachWidgetTreeToRenderTree(RenderProxyBox container) {
|
||||
),
|
||||
),
|
||||
),
|
||||
).attachToRenderTree(owner, element);
|
||||
).attachToRenderTree(WidgetsBinding.instance!.buildOwner!, element);
|
||||
}
|
||||
|
||||
Duration? timeBase;
|
||||
@@ -87,7 +86,7 @@ void rotate(Duration timeStamp) {
|
||||
transformBox.setIdentity();
|
||||
transformBox.rotateZ(delta);
|
||||
|
||||
owner.buildScope(element!);
|
||||
WidgetsBinding.instance!.buildOwner!.buildScope(element!);
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
Reference in New Issue
Block a user