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
6e50ccc8
Commit
6e50ccc8
authored
Mar 26, 2019
by
hyjfine
Committed by
xster
Mar 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Let CupertinoTextField's clear button also call onChanged (#29474)
parent
b5700506
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
3 deletions
+38
-3
text_field.dart
packages/flutter/lib/src/cupertino/text_field.dart
+8
-3
text_field_test.dart
packages/flutter/test/cupertino/text_field_test.dart
+30
-0
No files found.
packages/flutter/lib/src/cupertino/text_field.dart
View file @
6e50ccc8
...
...
@@ -660,9 +660,14 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with AutomaticK
}
else
if
(
_showClearButton
(
text
))
{
rowChildren
.
add
(
GestureDetector
(
onTap:
widget
.
enabled
??
true
?
()
=>
_effectiveController
.
clear
()
:
null
,
onTap:
widget
.
enabled
??
true
?
()
{
// Special handle onChanged for ClearButton
// Also call onChanged when the clear button is tapped.
final
bool
textChanged
=
_effectiveController
.
text
.
isNotEmpty
;
_effectiveController
.
clear
();
if
(
widget
.
onChanged
!=
null
&&
textChanged
)
widget
.
onChanged
(
_effectiveController
.
text
);
}
:
null
,
child:
const
Padding
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
6.0
),
child:
Icon
(
...
...
packages/flutter/test/cupertino/text_field_test.dart
View file @
6e50ccc8
...
...
@@ -749,6 +749,36 @@ void main() {
},
);
testWidgets
(
'tapping clear button also calls onChanged when text not empty'
,
(
WidgetTester
tester
)
async
{
String
value
=
'text entry'
;
final
TextEditingController
controller
=
TextEditingController
();
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
Center
(
child:
CupertinoTextField
(
controller:
controller
,
placeholder:
'placeholder'
,
onChanged:
(
String
newValue
)
=>
value
=
newValue
,
clearButtonMode:
OverlayVisibilityMode
.
always
,
),
),
),
);
controller
.
text
=
value
;
await
tester
.
pump
();
await
tester
.
tap
(
find
.
byIcon
(
CupertinoIcons
.
clear_thick_circled
));
await
tester
.
pump
();
expect
(
controller
.
text
,
isEmpty
);
expect
(
find
.
text
(
'text entry'
),
findsNothing
);
expect
(
value
,
isEmpty
);
},
);
testWidgets
(
'clear button yields precedence to suffix'
,
(
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