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
1eb6a95f
Unverified
Commit
1eb6a95f
authored
Jan 03, 2018
by
xster
Committed by
GitHub
Jan 03, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pipe onsubmit for text form fields (#13687)
parent
5e2bc168
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
0 deletions
+46
-0
text_form_field_demo.dart
...utter_gallery/lib/demo/material/text_form_field_demo.dart
+1
-0
text_form_field.dart
packages/flutter/lib/src/material/text_form_field.dart
+2
-0
text_form_field_test.dart
packages/flutter/test/material/text_form_field_test.dart
+22
-0
test_text_input.dart
packages/flutter_test/lib/src/test_text_input.dart
+21
-0
No files found.
examples/flutter_gallery/lib/demo/material/text_form_field_demo.dart
View file @
1eb6a95f
...
...
@@ -184,6 +184,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
labelText:
'Re-type Password *'
,
),
obscureText:
true
,
onFieldSubmitted:
(
String
value
)
{
_handleSubmitted
();
},
validator:
_validatePassword
,
),
),
...
...
packages/flutter/lib/src/material/text_form_field.dart
View file @
1eb6a95f
...
...
@@ -53,6 +53,7 @@ class TextFormField extends FormField<String> {
bool
obscureText:
false
,
bool
autocorrect:
true
,
int
maxLines:
1
,
ValueChanged
<
String
>
onFieldSubmitted
,
FormFieldSetter
<
String
>
onSaved
,
FormFieldValidator
<
String
>
validator
,
List
<
TextInputFormatter
>
inputFormatters
,
...
...
@@ -82,6 +83,7 @@ class TextFormField extends FormField<String> {
autocorrect:
autocorrect
,
maxLines:
maxLines
,
onChanged:
field
.
onChanged
,
onSubmitted:
onFieldSubmitted
,
inputFormatters:
inputFormatters
,
);
},
...
...
packages/flutter/test/material/text_form_field_test.dart
View file @
1eb6a95f
...
...
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
...
...
@@ -27,4 +28,25 @@ void main() {
final
TextField
textFieldWidget
=
tester
.
widget
(
textFieldFinder
);
expect
(
textFieldWidget
.
textAlign
,
alignment
);
});
testWidgets
(
'onFieldSubmit callbacks are called'
,
(
WidgetTester
tester
)
async
{
bool
_called
=
false
;
await
tester
.
pumpWidget
(
new
MaterialApp
(
home:
new
Material
(
child:
new
Center
(
child:
new
TextFormField
(
onFieldSubmitted:
(
String
value
)
{
_called
=
true
;
},
),
),
),
),
);
await
tester
.
showKeyboard
(
find
.
byType
(
TextField
));
tester
.
testTextInput
.
receiveAction
(
TextInputAction
.
done
);
await
tester
.
pump
();
expect
(
_called
,
true
);
});
}
packages/flutter_test/lib/src/test_text_input.dart
View file @
1eb6a95f
...
...
@@ -106,6 +106,27 @@ class TestTextInput {
));
}
/// Simulates the user pressing one of the [TextInputAction] buttons.
/// Does not check that the [TextInputAction] performed is an acceptable one
/// based on the `inputAction` [setClientArgs].
void
receiveAction
(
TextInputAction
action
)
{
// Not using the `expect` function because in the case of a FlutterDriver
// test this code does not run in a package:test test zone.
if
(
_client
==
0
)
{
throw
new
TestFailure
(
'_client must be non-zero'
);
}
BinaryMessages
.
handlePlatformMessage
(
SystemChannels
.
textInput
.
name
,
SystemChannels
.
textInput
.
codec
.
encodeMethodCall
(
new
MethodCall
(
'TextInputClient.performAction'
,
<
dynamic
>[
_client
,
action
.
toString
()],
),
),
(
ByteData
data
)
{
/* response from framework is discarded */
},
);
}
/// Simulates the user hiding the onscreen keyboard.
void
hide
()
{
_isVisible
=
false
;
...
...
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