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
324fe201
Unverified
Commit
324fe201
authored
Aug 19, 2019
by
Matt Carroll
Committed by
GitHub
Aug 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add handling of 'TextInput.clearClient' message from platform to framework (#35054). (#35100)
parent
d2bc74aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
4 deletions
+53
-4
text_input.dart
packages/flutter/lib/src/services/text_input.dart
+14
-4
text_input_test.dart
packages/flutter/test/services/text_input_test.dart
+39
-0
No files found.
packages/flutter/lib/src/services/text_input.dart
View file @
324fe201
...
...
@@ -632,7 +632,7 @@ abstract class TextInputClient {
/// See also:
///
/// * [TextInput.attach]
class
TextInputConnection
{
class
TextInputConnection
with
ChangeNotifier
{
TextInputConnection
.
_
(
this
.
_client
)
:
assert
(
_client
!=
null
),
_id
=
_nextId
++;
...
...
@@ -667,12 +667,19 @@ class TextInputConnection {
void
close
()
{
if
(
attached
)
{
SystemChannels
.
textInput
.
invokeMethod
<
void
>(
'TextInput.clearClient'
);
_clientHandler
..
_currentConnection
=
null
..
_scheduleHide
();
_onConnectionClosed
();
_clientHandler
.
_scheduleHide
();
}
assert
(!
attached
);
}
/// Clear out the current text input connection.
///
/// Call this method when the current text input connection has cleared.
void
_onConnectionClosed
()
{
_clientHandler
.
_currentConnection
=
null
;
notifyListeners
();
}
}
TextInputAction
_toTextInputAction
(
String
action
)
{
...
...
@@ -753,6 +760,9 @@ class _TextInputClientHandler {
case
'TextInputClient.updateFloatingCursor'
:
_currentConnection
.
_client
.
updateFloatingCursor
(
_toTextPoint
(
_toTextCursorAction
(
args
[
1
]),
args
[
2
]));
break
;
case
'TextInputClient.onConnectionClosed'
:
_currentConnection
.
_onConnectionClosed
();
break
;
default
:
throw
MissingPluginException
();
}
...
...
packages/flutter/test/services/text_input_test.dart
View file @
324fe201
...
...
@@ -85,5 +85,44 @@ void main() {
expect
(
signed
.
hashCode
==
signedDecimal
.
hashCode
,
false
);
expect
(
decimal
.
hashCode
==
signedDecimal
.
hashCode
,
false
);
});
test
(
'The framework TextInputConnection closes when the platform loses its input connection'
,
()
async
{
// Assemble a TextInputConnection so we can verify its change in state.
final
TextInputClient
client
=
NoOpTextInputClient
();
const
TextInputConfiguration
configuration
=
TextInputConfiguration
();
final
TextInputConnection
textInputConnection
=
TextInput
.
attach
(
client
,
configuration
);
// Verify that TextInputConnection think its attached to a client. This is
// an intermediate verification of expected state.
expect
(
textInputConnection
.
attached
,
true
);
// Pretend that the platform has lost its input connection.
final
ByteData
messageBytes
=
const
JSONMessageCodec
().
encodeMessage
(
<
String
,
dynamic
>{
'args'
:
<
dynamic
>[
1
],
'method'
:
'TextInputClient.onConnectionClosed'
,
}
);
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/textinput'
,
messageBytes
,
(
ByteData
_
)
{},
);
// Verify that textInputConnection no longer think its attached to an input
// connection. This is the critical verification of this test.
expect
(
textInputConnection
.
attached
,
false
);
});
});
}
class
NoOpTextInputClient
extends
TextInputClient
{
@override
void
performAction
(
TextInputAction
action
)
{}
@override
void
updateEditingValue
(
TextEditingValue
value
)
{}
@override
void
updateFloatingCursor
(
RawFloatingCursorPoint
point
)
{}
}
\ No newline at end of file
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