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
b6349e7d
Commit
b6349e7d
authored
Jun 27, 2019
by
Kasper
Committed by
LongCatIsLooong
Jun 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added onChanged property to TextFormField (#34932)
parent
883d6ead
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletion
+30
-1
text_form_field.dart
packages/flutter/lib/src/material/text_form_field.dart
+8
-1
text_form_field_test.dart
packages/flutter/test/material/text_form_field_test.dart
+22
-0
No files found.
packages/flutter/lib/src/material/text_form_field.dart
View file @
b6349e7d
...
...
@@ -98,6 +98,7 @@ class TextFormField extends FormField<String> {
int
minLines
,
bool
expands
=
false
,
int
maxLength
,
ValueChanged
<
String
>
onChanged
,
VoidCallback
onEditingComplete
,
ValueChanged
<
String
>
onFieldSubmitted
,
FormFieldSetter
<
String
>
onSaved
,
...
...
@@ -144,6 +145,12 @@ class TextFormField extends FormField<String> {
final
_TextFormFieldState
state
=
field
;
final
InputDecoration
effectiveDecoration
=
(
decoration
??
const
InputDecoration
())
.
applyDefaults
(
Theme
.
of
(
field
.
context
).
inputDecorationTheme
);
void
onChangedHandler
(
String
value
)
{
if
(
onChanged
!=
null
)
{
onChanged
(
value
);
}
field
.
didChange
(
value
);
}
return
TextField
(
controller:
state
.
_effectiveController
,
focusNode:
focusNode
,
...
...
@@ -165,7 +172,7 @@ class TextFormField extends FormField<String> {
minLines:
minLines
,
expands:
expands
,
maxLength:
maxLength
,
onChanged:
field
.
didChange
,
onChanged:
onChangedHandler
,
onEditingComplete:
onEditingComplete
,
onSubmitted:
onFieldSubmitted
,
inputFormatters:
inputFormatters
,
...
...
packages/flutter/test/material/text_form_field_test.dart
View file @
b6349e7d
...
...
@@ -123,6 +123,28 @@ void main() {
expect
(
_called
,
true
);
});
testWidgets
(
'onChanged callbacks are called'
,
(
WidgetTester
tester
)
async
{
String
_value
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Material
(
child:
Center
(
child:
TextFormField
(
onChanged:
(
String
value
)
{
_value
=
value
;
},
),
),
),
),
);
await
tester
.
enterText
(
find
.
byType
(
TextField
),
'Soup'
);
await
tester
.
pump
();
expect
(
_value
,
'Soup'
);
});
testWidgets
(
'autovalidate is passed to super'
,
(
WidgetTester
tester
)
async
{
int
_validateCalled
=
0
;
...
...
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