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
b6cca392
Unverified
Commit
b6cca392
authored
Mar 14, 2018
by
Hans Muller
Committed by
GitHub
Mar 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated the gallery text fields demo (#15362)
parent
c345c1bb
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
179 additions
and
95 deletions
+179
-95
text_form_field_demo.dart
...utter_gallery/lib/demo/material/text_form_field_demo.dart
+154
-91
text_form_field_demo_test.dart
...gallery/test/demo/material/text_form_field_demo_test.dart
+19
-4
text_form_field.dart
packages/flutter/lib/src/material/text_form_field.dart
+6
-0
No files found.
examples/flutter_gallery/lib/demo/material/text_form_field_demo.dart
View file @
b6cca392
This diff is collapsed.
Click to expand it.
examples/flutter_gallery/test/demo/material/text_form_field_demo_test.dart
View file @
b6cca392
...
...
@@ -16,21 +16,36 @@ void main() {
final
Finder
nameField
=
find
.
widgetWithText
(
TextFormField
,
'Name *'
);
expect
(
nameField
,
findsOneWidget
);
final
Finder
passwordField
=
find
.
widgetWithText
(
TextFormField
,
'Password *'
);
expect
(
passwordField
,
findsOneWidget
);
await
tester
.
enterText
(
nameField
,
''
);
// The submit button isn't initially visible. Drag it into view so that
// it will see the tap.
await
tester
.
drag
(
nameField
,
const
Offset
(
0.0
,
-
1200.0
));
await
tester
.
pumpAndSettle
();
await
tester
.
tap
(
submitButton
);
await
tester
.
pump
();
await
tester
.
pumpAndSettle
();
// Now drag the password field (the submit button will be obscured by
// the snackbar) and expose the name field again.
await
tester
.
drag
(
passwordField
,
const
Offset
(
0.0
,
1200.0
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Name is required.'
),
findsOneWidget
);
expect
(
find
.
text
(
'Please enter only alphabetical characters.'
),
findsNothing
);
await
tester
.
enterText
(
nameField
,
'#'
);
// Make the submit button visible again (by dragging the name field), so
// it will see the tap.
await
tester
.
drag
(
nameField
,
const
Offset
(
0.0
,
-
1200.0
));
await
tester
.
tap
(
submitButton
);
await
tester
.
pump
();
await
tester
.
pump
AndSettle
();
expect
(
find
.
text
(
'Name is required.'
),
findsNothing
);
expect
(
find
.
text
(
'Please enter only alphabetical characters.'
),
findsOneWidget
);
await
tester
.
enterText
(
nameField
,
'Jane Doe'
);
await
tester
.
tap
(
submitButton
);
await
tester
.
pump
();
await
tester
.
pump
AndSettle
();
expect
(
find
.
text
(
'Name is required.'
),
findsNothing
);
expect
(
find
.
text
(
'Please enter only alphabetical characters.'
),
findsNothing
);
});
...
...
packages/flutter/lib/src/material/text_form_field.dart
View file @
b6cca392
...
...
@@ -60,7 +60,9 @@ class TextFormField extends FormField<String> {
bool
autofocus:
false
,
bool
obscureText:
false
,
bool
autocorrect:
true
,
bool
maxLengthEnforced:
true
,
int
maxLines:
1
,
int
maxLength
,
ValueChanged
<
String
>
onFieldSubmitted
,
FormFieldSetter
<
String
>
onSaved
,
FormFieldValidator
<
String
>
validator
,
...
...
@@ -71,7 +73,9 @@ class TextFormField extends FormField<String> {
assert
(
autofocus
!=
null
),
assert
(
obscureText
!=
null
),
assert
(
autocorrect
!=
null
),
assert
(
maxLengthEnforced
!=
null
),
assert
(
maxLines
==
null
||
maxLines
>
0
),
assert
(
maxLength
==
null
||
maxLength
>
0
),
super
(
key:
key
,
initialValue:
controller
!=
null
?
controller
.
text
:
(
initialValue
??
''
),
...
...
@@ -91,7 +95,9 @@ class TextFormField extends FormField<String> {
autofocus:
autofocus
,
obscureText:
obscureText
,
autocorrect:
autocorrect
,
maxLengthEnforced:
maxLengthEnforced
,
maxLines:
maxLines
,
maxLength:
maxLength
,
onChanged:
field
.
onChanged
,
onSubmitted:
onFieldSubmitted
,
inputFormatters:
inputFormatters
,
...
...
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