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
b9195d80
Unverified
Commit
b9195d80
authored
Oct 26, 2020
by
Justin McCandless
Committed by
GitHub
Oct 26, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "change TextEditingController.clear() behavior (#68775)" (#68920)
This reverts commit
95909c2a
.
parent
fdac8a9d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
75 deletions
+2
-75
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+2
-2
editable_text_test.dart
packages/flutter/test/widgets/editable_text_test.dart
+0
-73
No files found.
packages/flutter/lib/src/widgets/editable_text.dart
View file @
b9195d80
...
...
@@ -230,14 +230,14 @@ class TextEditingController extends ValueNotifier<TextEditingValue> {
/// Set the [value] to empty.
///
/// After calling this function, [text] will be the empty string and the
/// selection will be
collapsed at zero offset
.
/// selection will be
invalid
.
///
/// Calling this will notify all the listeners of this [TextEditingController]
/// that they need to update (it calls [notifyListeners]). For this reason,
/// this method should only be called between frames, e.g. in response to user
/// actions, not during the build, layout, or paint phases.
void
clear
()
{
value
=
const
TextEditingValue
(
selection:
TextSelection
.
collapsed
(
offset:
0
))
;
value
=
TextEditingValue
.
empty
;
}
/// Set the composing region to an empty range.
...
...
packages/flutter/test/widgets/editable_text_test.dart
View file @
b9195d80
...
...
@@ -5391,79 +5391,6 @@ void main() {
expect
(
focusNode
.
hasFocus
,
false
);
});
testWidgets
(
'TextEditingController.clear() behavior test'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/66316
final
List
<
MethodCall
>
log
=
<
MethodCall
>[];
SystemChannels
.
textInput
.
setMockMethodCallHandler
((
MethodCall
methodCall
)
async
{
log
.
add
(
methodCall
);
});
final
TextEditingController
controller
=
TextEditingController
();
final
FocusNode
focusNode
=
FocusNode
(
debugLabel:
'EditableText Focus Node'
);
Widget
builder
()
{
return
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setter
)
{
return
MaterialApp
(
home:
MediaQuery
(
data:
const
MediaQueryData
(
devicePixelRatio:
1.0
),
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
Material
(
child:
EditableText
(
controller:
controller
,
focusNode:
focusNode
,
style:
textStyle
,
cursorColor:
Colors
.
red
,
backgroundCursorColor:
Colors
.
red
,
keyboardType:
TextInputType
.
multiline
,
onChanged:
(
String
value
)
{
},
),
),
),
),
),
);
},
);
}
await
tester
.
pumpWidget
(
builder
());
await
tester
.
tap
(
find
.
byType
(
EditableText
));
await
tester
.
pump
();
// The keyboard is shown after tap the EditableText.
expect
(
focusNode
.
hasFocus
,
true
);
log
.
clear
();
final
EditableTextState
state
=
tester
.
firstState
(
find
.
byType
(
EditableText
));
state
.
updateEditingValue
(
const
TextEditingValue
(
text:
'a'
,
));
await
tester
.
pump
();
// Nothing called when only the remote changes.
expect
(
log
.
length
,
0
);
controller
.
clear
();
expect
(
log
.
length
,
1
);
expect
(
log
[
0
],
isMethodCall
(
'TextInput.setEditingState'
,
arguments:
<
String
,
dynamic
>{
'text'
:
''
,
'selectionBase'
:
0
,
'selectionExtent'
:
0
,
'selectionAffinity'
:
'TextAffinity.downstream'
,
'selectionIsDirectional'
:
false
,
'composingBase'
:
-
1
,
'composingExtent'
:
-
1
,
}),
);
});
testWidgets
(
'autofocus:true on first frame does not throw'
,
(
WidgetTester
tester
)
async
{
final
TextEditingController
controller
=
TextEditingController
(
text:
testText
);
controller
.
selection
=
const
TextSelection
(
...
...
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