Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
7ec3f6bd
Unverified
Commit
7ec3f6bd
authored
Dec 08, 2020
by
Todd Volkert
Committed by
GitHub
Dec 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make FocusManager configurable in BuildOwner (#71872)
parent
7324ade3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
2 deletions
+42
-2
pointer_router.dart
packages/flutter/lib/src/gestures/pointer_router.dart
+16
-0
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+3
-2
framework_test.dart
packages/flutter/test/widgets/framework_test.dart
+23
-0
No files found.
packages/flutter/lib/src/gestures/pointer_router.dart
View file @
7ec3f6bd
...
...
@@ -71,6 +71,22 @@ class PointerRouter {
_globalRoutes
.
remove
(
route
);
}
/// The number of global routes that have been registered.
///
/// This is valid in debug builds only. In release builds, this will throw an
/// [UnsupportedError].
int
get
debugGlobalRouteCount
{
int
?
count
;
assert
(()
{
count
=
_globalRoutes
.
length
;
return
true
;
}());
if
(
count
!=
null
)
{
return
count
!;
}
throw
UnsupportedError
(
'debugGlobalRouteCount is not supported in release builds'
);
}
void
_dispatch
(
PointerEvent
event
,
PointerRoute
route
,
Matrix4
?
transform
)
{
try
{
event
=
event
.
transformed
(
transform
);
...
...
packages/flutter/lib/src/widgets/framework.dart
View file @
7ec3f6bd
...
...
@@ -2554,7 +2554,8 @@ abstract class BuildContext {
/// widget tree.
class
BuildOwner
{
/// Creates an object that manages widgets.
BuildOwner
({
this
.
onBuildScheduled
});
BuildOwner
({
this
.
onBuildScheduled
,
FocusManager
?
focusManager
})
:
focusManager
=
focusManager
??
FocusManager
();
/// Called on each build pass when the first buildable element is marked
/// dirty.
...
...
@@ -2585,7 +2586,7 @@ class BuildOwner {
/// the [FocusScopeNode] for a given [BuildContext].
///
/// See [FocusManager] for more details.
FocusManager
focusManager
=
FocusManager
()
;
FocusManager
focusManager
;
/// Adds an element to the dirty elements list so that it will be rebuilt
/// when [WidgetsBinding.drawFrame] calls [buildScope].
...
...
packages/flutter/test/widgets/framework_test.dart
View file @
7ec3f6bd
...
...
@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
@@ -1483,6 +1485,27 @@ void main() {
)
);
});
testWidgets
(
'Can create BuildOwner that does not interfere with pointer router or raw key event handler'
,
(
WidgetTester
tester
)
async
{
final
int
pointerRouterCount
=
GestureBinding
.
instance
!.
pointerRouter
.
debugGlobalRouteCount
;
final
RawKeyEventHandler
?
rawKeyEventHandler
=
RawKeyboard
.
instance
.
keyEventHandler
;
expect
(
rawKeyEventHandler
,
isNotNull
);
BuildOwner
(
focusManager:
_FakeFocusManager
());
expect
(
GestureBinding
.
instance
!.
pointerRouter
.
debugGlobalRouteCount
,
pointerRouterCount
);
expect
(
RawKeyboard
.
instance
.
keyEventHandler
,
same
(
rawKeyEventHandler
));
});
}
class
_FakeFocusManager
implements
FocusManager
{
@override
dynamic
noSuchMethod
(
Invocation
invocation
)
{
return
super
.
noSuchMethod
(
invocation
);
}
@override
String
toString
({
DiagnosticLevel
minLevel
=
DiagnosticLevel
.
info
})
{
return
'_FakeFocusManager'
;
}
}
class
_WidgetWithNoVisitChildren
extends
StatelessWidget
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment