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
12d5b26c
Commit
12d5b26c
authored
Jan 09, 2017
by
Matt Perry
Committed by
GitHub
Jan 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an onChanged callback to InputFormField. (#7398)
Fixes
https://github.com/flutter/flutter/issues/7210
parent
7c9f9be3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
1 deletion
+37
-1
input.dart
packages/flutter/lib/src/material/input.dart
+6
-1
form_test.dart
packages/flutter/test/widgets/form_test.dart
+31
-0
No files found.
packages/flutter/lib/src/material/input.dart
View file @
12d5b26c
...
@@ -629,6 +629,7 @@ class InputFormField extends FormField<InputValue> {
...
@@ -629,6 +629,7 @@ class InputFormField extends FormField<InputValue> {
InputValue
initialValue:
InputValue
.
empty
,
InputValue
initialValue:
InputValue
.
empty
,
FormFieldSetter
<
InputValue
>
onSaved
,
FormFieldSetter
<
InputValue
>
onSaved
,
FormFieldValidator
<
InputValue
>
validator
,
FormFieldValidator
<
InputValue
>
validator
,
ValueChanged
<
InputValue
>
onChanged
,
})
:
super
(
})
:
super
(
key:
key
,
key:
key
,
initialValue:
initialValue
,
initialValue:
initialValue
,
...
@@ -647,7 +648,11 @@ class InputFormField extends FormField<InputValue> {
...
@@ -647,7 +648,11 @@ class InputFormField extends FormField<InputValue> {
autofocus:
autofocus
,
autofocus:
autofocus
,
maxLines:
maxLines
,
maxLines:
maxLines
,
value:
field
.
value
,
value:
field
.
value
,
onChanged:
field
.
onChanged
,
onChanged:
(
InputValue
value
)
{
field
.
onChanged
(
value
);
if
(
onChanged
!=
null
)
onChanged
(
value
);
},
errorText:
field
.
errorText
,
errorText:
field
.
errorText
,
);
);
},
},
...
...
packages/flutter/test/widgets/form_test.dart
View file @
12d5b26c
...
@@ -54,6 +54,37 @@ void main() {
...
@@ -54,6 +54,37 @@ void main() {
await
checkText
(
''
);
await
checkText
(
''
);
});
});
testWidgets
(
'onChanged callback is called'
,
(
WidgetTester
tester
)
async
{
String
fieldValue
;
Widget
builder
()
{
return
new
Center
(
child:
new
Material
(
child:
new
Form
(
child:
new
InputFormField
(
onChanged:
(
InputValue
value
)
{
fieldValue
=
value
.
text
;
},
),
)
)
);
}
await
tester
.
pumpWidget
(
builder
());
await
showKeyboard
(
tester
);
expect
(
fieldValue
,
isNull
);
Future
<
Null
>
checkText
(
String
testValue
)
async
{
enterText
(
testValue
);
await
tester
.
idle
();
// pump'ing is unnecessary because callback happens regardless of frames
expect
(
fieldValue
,
equals
(
testValue
));
}
await
checkText
(
'Test'
);
await
checkText
(
''
);
});
testWidgets
(
'Validator sets the error text only when validate is called'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Validator sets the error text only when validate is called'
,
(
WidgetTester
tester
)
async
{
GlobalKey
<
FormState
>
formKey
=
new
GlobalKey
<
FormState
>();
GlobalKey
<
FormState
>
formKey
=
new
GlobalKey
<
FormState
>();
GlobalKey
inputKey
=
new
GlobalKey
();
GlobalKey
inputKey
=
new
GlobalKey
();
...
...
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