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
734df6f5
Unverified
Commit
734df6f5
authored
Jun 10, 2021
by
Emmanuel Garcia
Committed by
GitHub
Jun 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow Flutter focus to interop with Android view hierarchies (#84055)
parent
17b024a5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
4 deletions
+63
-4
platform_view.dart
packages/flutter/lib/src/widgets/platform_view.dart
+5
-1
platform_view_test.dart
packages/flutter/test/widgets/platform_view_test.dart
+58
-3
No files found.
packages/flutter/lib/src/widgets/platform_view.dart
View file @
734df6f5
...
...
@@ -537,7 +537,7 @@ class _AndroidViewState extends State<AndroidView> {
}
SystemChannels
.
textInput
.
invokeMethod
<
void
>(
'TextInput.setPlatformViewClient'
,
_id
,
<
String
,
dynamic
>{
'platformViewId'
:
_id
,
'usesVirtualDisplay'
:
true
}
,
).
catchError
((
dynamic
e
)
{
if
(
e
is
MissingPluginException
)
{
// We land the framework part of Android platform views keyboard
...
...
@@ -893,6 +893,10 @@ class _PlatformViewLinkState extends State<PlatformViewLink> {
if
(!
isFocused
)
{
_controller
?.
clearFocus
();
}
SystemChannels
.
textInput
.
invokeMethod
<
void
>(
'TextInput.setPlatformViewClient'
,
<
String
,
dynamic
>{
'platformViewId'
:
_id
},
);
}
void
_handlePlatformFocusChanged
(
bool
isFocused
){
...
...
packages/flutter/test/widgets/platform_view_test.dart
View file @
734df6f5
...
...
@@ -1074,10 +1074,10 @@ void main() {
containerFocusNode
.
requestFocus
();
await
tester
.
pump
();
late
int
lastPlatformViewTextClient
;
late
Map
<
String
,
dynamic
>
lastPlatformViewTextClient
;
tester
.
binding
.
defaultBinaryMessenger
.
setMockMethodCallHandler
(
SystemChannels
.
textInput
,
(
MethodCall
call
)
{
if
(
call
.
method
==
'TextInput.setPlatformViewClient'
)
{
lastPlatformViewTextClient
=
call
.
arguments
as
int
;
lastPlatformViewTextClient
=
call
.
arguments
as
Map
<
String
,
dynamic
>
;
}
return
null
;
});
...
...
@@ -1085,7 +1085,11 @@ void main() {
viewsController
.
invokeViewFocused
(
currentViewId
+
1
);
await
tester
.
pump
();
expect
(
lastPlatformViewTextClient
,
currentViewId
+
1
);
expect
(
lastPlatformViewTextClient
.
containsKey
(
'platformViewId'
),
true
);
expect
(
lastPlatformViewTextClient
[
'platformViewId'
],
currentViewId
+
1
);
expect
(
lastPlatformViewTextClient
.
containsKey
(
'usesVirtualDisplay'
),
true
);
expect
(
lastPlatformViewTextClient
[
'usesVirtualDisplay'
],
true
);
});
testWidgets
(
'AndroidView clears platform focus when unfocused'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -2560,6 +2564,57 @@ void main() {
expect
(
platformViewFocusNode
.
hasFocus
,
false
);
expect
(
controller
.
focusCleared
,
true
);
});
testWidgets
(
'PlatformViewLink sets a platform view text input client when focused'
,
(
WidgetTester
tester
)
async
{
late
FakePlatformViewController
controller
;
late
int
viewId
;
final
PlatformViewLink
platformViewLink
=
PlatformViewLink
(
viewType:
'test'
,
onCreatePlatformView:
(
PlatformViewCreationParams
params
)
{
viewId
=
params
.
id
;
params
.
onPlatformViewCreated
(
params
.
id
);
controller
=
FakePlatformViewController
(
params
.
id
);
return
controller
;
},
surfaceFactory:
(
BuildContext
context
,
PlatformViewController
controller
)
{
return
PlatformViewSurface
(
gestureRecognizers:
const
<
Factory
<
OneSequenceGestureRecognizer
>>{},
controller:
controller
,
hitTestBehavior:
PlatformViewHitTestBehavior
.
opaque
,
);
},
);
await
tester
.
pumpWidget
(
SizedBox
(
width:
300
,
height:
300
,
child:
platformViewLink
));
final
Focus
platformViewFocusWidget
=
tester
.
widget
(
find
.
descendant
(
of:
find
.
byType
(
PlatformViewLink
),
matching:
find
.
byType
(
Focus
),
),
);
final
FocusNode
?
focusNode
=
platformViewFocusWidget
.
focusNode
;
expect
(
focusNode
,
isNotNull
);
expect
(
focusNode
!.
hasFocus
,
false
);
late
Map
<
String
,
dynamic
>
lastPlatformViewTextClient
;
tester
.
binding
.
defaultBinaryMessenger
.
setMockMethodCallHandler
(
SystemChannels
.
textInput
,
(
MethodCall
call
)
{
if
(
call
.
method
==
'TextInput.setPlatformViewClient'
)
{
lastPlatformViewTextClient
=
call
.
arguments
as
Map
<
String
,
dynamic
>;
}
return
null
;
});
platformViewFocusWidget
.
focusNode
!.
requestFocus
();
await
tester
.
pump
();
expect
(
focusNode
.
hasFocus
,
true
);
expect
(
lastPlatformViewTextClient
.
containsKey
(
'platformViewId'
),
true
);
expect
(
lastPlatformViewTextClient
[
'platformViewId'
],
viewId
);
expect
(
lastPlatformViewTextClient
.
containsKey
(
'usesVirtualDisplay'
),
false
);
});
});
testWidgets
(
'Platform views respect hitTestBehavior'
,
(
WidgetTester
tester
)
async
{
...
...
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