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
b73722b1
Unverified
Commit
b73722b1
authored
Jan 15, 2021
by
J-P Nurmi
Committed by
GitHub
Jan 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[text_input] prepare for custom text input sources (#72803)
parent
58301211
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
354 additions
and
185 deletions
+354
-185
text_input.dart
packages/flutter/lib/src/services/text_input.dart
+293
-183
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+1
-2
text_input_test.dart
packages/flutter/test/services/text_input_test.dart
+60
-0
No files found.
packages/flutter/lib/src/services/text_input.dart
View file @
b73722b1
This diff is collapsed.
Click to expand it.
packages/flutter/lib/src/widgets/editable_text.dart
View file @
b73722b1
...
...
@@ -2038,7 +2038,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
void
_closeInputConnectionIfNeeded
()
{
if
(
_hasInputConnection
)
{
_textInputConnection
!.
close
(
);
TextInput
.
detach
(
this
);
_textInputConnection
=
null
;
_lastKnownRemoteTextEditingValue
=
null
;
}
...
...
@@ -2056,7 +2056,6 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
@override
void
connectionClosed
()
{
if
(
_hasInputConnection
)
{
_textInputConnection
!.
connectionClosedReceived
();
_textInputConnection
=
null
;
_lastKnownRemoteTextEditingValue
=
null
;
_finalizeEditing
(
TextInputAction
.
done
,
shouldUnfocus:
true
);
...
...
packages/flutter/test/services/text_input_test.dart
View file @
b73722b1
...
...
@@ -22,6 +22,7 @@ void main() {
});
tearDown
(()
{
TextInput
.
reset
();
TextInputConnection
.
debugResetId
();
TextInput
.
setChannel
(
SystemChannels
.
textInput
);
});
...
...
@@ -74,6 +75,65 @@ void main() {
}),
]);
});
test
(
'text input client is requested to hide on detach'
,
()
async
{
final
FakeTextInputClient
client
=
FakeTextInputClient
(
TextEditingValue
.
empty
);
TextInput
.
attach
(
client
,
client
.
configuration
);
fakeTextChannel
.
validateOutgoingMethodCalls
(<
MethodCall
>[
MethodCall
(
'TextInput.setClient'
,
<
dynamic
>[
1
,
client
.
configuration
.
toJson
()]),
]);
TextInput
.
detach
(
client
);
fakeTextChannel
.
validateOutgoingMethodCalls
(<
MethodCall
>[
// From original attach
MethodCall
(
'TextInput.setClient'
,
<
dynamic
>[
1
,
client
.
configuration
.
toJson
()]),
// From detach
const
MethodCall
(
'TextInput.clearClient'
),
]);
final
TestWidgetsFlutterBinding
binding
=
TestWidgetsFlutterBinding
.
ensureInitialized
()
as
TestWidgetsFlutterBinding
;
await
binding
.
runAsync
(()
async
{});
await
expectLater
(
fakeTextChannel
.
outgoingCalls
.
length
,
3
);
fakeTextChannel
.
validateOutgoingMethodCalls
(<
MethodCall
>[
// From original attach
MethodCall
(
'TextInput.setClient'
,
<
dynamic
>[
1
,
client
.
configuration
.
toJson
()]),
// From detach
const
MethodCall
(
'TextInput.clearClient'
),
// From hide
const
MethodCall
(
'TextInput.hide'
),
]);
});
test
(
'old client is detached when a new client is attached'
,()
{
final
FakeTextInputClient
client1
=
FakeTextInputClient
(
const
TextEditingValue
(
text:
'1'
));
final
TextInputConnection
connection1
=
TextInput
.
attach
(
client1
,
client1
.
configuration
);
expect
(
connection1
.
attached
,
isTrue
);
fakeTextChannel
.
validateOutgoingMethodCalls
(<
MethodCall
>[
MethodCall
(
'TextInput.setClient'
,
<
dynamic
>[
1
,
client1
.
configuration
.
toJson
()]),
]);
final
FakeTextInputClient
client2
=
FakeTextInputClient
(
const
TextEditingValue
(
text:
'1'
));
final
TextInputConnection
connection2
=
TextInput
.
attach
(
client2
,
client2
.
configuration
);
expect
(
connection2
.
attached
,
isTrue
);
expect
(
connection1
.
attached
,
isFalse
);
fakeTextChannel
.
validateOutgoingMethodCalls
(<
MethodCall
>[
// From original attach
MethodCall
(
'TextInput.setClient'
,
<
dynamic
>[
1
,
client1
.
configuration
.
toJson
()]),
// From internal detach
const
MethodCall
(
'TextInput.clearClient'
),
// From second attach
MethodCall
(
'TextInput.setClient'
,
<
dynamic
>[
2
,
client1
.
configuration
.
toJson
()]),
]);
});
test
(
'text input connection is reset'
,
()
async
{
final
FakeTextInputClient
client
=
FakeTextInputClient
(
TextEditingValue
.
empty
);
final
TextInputConnection
connection
=
TextInput
.
attach
(
client
,
client
.
configuration
);
expect
(
connection
.
attached
,
isTrue
);
TextInput
.
reset
();
expect
(
connection
.
attached
,
isFalse
);
});
});
group
(
'TextInputConfiguration'
,
()
{
...
...
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