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
11de1a51
Commit
11de1a51
authored
Sep 11, 2017
by
Todd Volkert
Committed by
GitHub
Sep 11, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix capitalization in gallery RegExp (#12035)
parent
e2c6ba1b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
1 deletion
+38
-1
text_form_field_demo.dart
...utter_gallery/lib/demo/material/text_form_field_demo.dart
+1
-1
text_form_field_demo_test.dart
...gallery/test/demo/material/text_form_field_demo_test.dart
+37
-0
No files found.
examples/flutter_gallery/lib/demo/material/text_form_field_demo.dart
View file @
11de1a51
...
...
@@ -53,7 +53,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
_formWasEdited
=
true
;
if
(
value
.
isEmpty
)
return
'Name is required.'
;
final
RegExp
nameExp
=
new
RegExp
(
r'^[A-
z
a-z ]+$'
);
final
RegExp
nameExp
=
new
RegExp
(
r'^[A-
Z
a-z ]+$'
);
if
(!
nameExp
.
hasMatch
(
value
))
return
'Please enter only alphabetical characters.'
;
return
null
;
...
...
examples/flutter_gallery/test/demo/material/text_form_field_demo_test.dart
0 → 100644
View file @
11de1a51
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/material.dart'
;
import
'package:flutter_gallery/demo/material/text_form_field_demo.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
testWidgets
(
'validates name field correctly'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
new
MaterialApp
(
home:
const
TextFormFieldDemo
()));
final
Finder
submitButton
=
find
.
widgetWithText
(
RaisedButton
,
'SUBMIT'
);
expect
(
submitButton
,
findsOneWidget
);
final
Finder
nameField
=
find
.
widgetWithText
(
TextFormField
,
'Name *'
);
expect
(
nameField
,
findsOneWidget
);
await
tester
.
enterText
(
nameField
,
''
);
await
tester
.
tap
(
submitButton
);
await
tester
.
pump
();
expect
(
find
.
text
(
'Name is required.'
),
findsOneWidget
);
expect
(
find
.
text
(
'Please enter only alphabetical characters.'
),
findsNothing
);
await
tester
.
enterText
(
nameField
,
'#'
);
await
tester
.
tap
(
submitButton
);
await
tester
.
pump
();
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
();
expect
(
find
.
text
(
'Name is required.'
),
findsNothing
);
expect
(
find
.
text
(
'Please enter only alphabetical characters.'
),
findsNothing
);
});
}
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