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
9573bc14
Commit
9573bc14
authored
Jan 22, 2017
by
Ian Hickson
Committed by
GitHub
Jan 22, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid double negatives in text editing APIs (#7577)
hideText -> obscureText hideDivider -> !showDivider
parent
15a7eb3b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
27 deletions
+51
-27
text_field_demo.dart
examples/flutter_gallery/lib/demo/text_field_demo.dart
+2
-2
input.dart
packages/flutter/lib/src/material/input.dart
+36
-16
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+11
-7
input_test.dart
packages/flutter/test/widgets/input_test.dart
+2
-2
No files found.
examples/flutter_gallery/lib/demo/text_field_demo.dart
View file @
9573bc14
...
...
@@ -141,7 +141,7 @@ class TextFieldDemoState extends State<TextFieldDemo> {
key:
_passwordFieldKey
,
hintText:
'How do you log in?'
,
labelText:
'New Password'
,
hid
eText:
true
,
obscur
eText:
true
,
onSaved:
(
InputValue
val
)
{
person
.
password
=
val
.
text
;
}
)
),
...
...
@@ -150,7 +150,7 @@ class TextFieldDemoState extends State<TextFieldDemo> {
child:
new
TextField
(
hintText:
'How do you log in?'
,
labelText:
'Re-type Password'
,
hid
eText:
true
,
obscur
eText:
true
,
validator:
_validatePassword
,
)
)
...
...
packages/flutter/lib/src/material/input.dart
View file @
9573bc14
...
...
@@ -47,7 +47,7 @@ class InputField extends StatefulWidget {
this
.
keyboardType
:
TextInputType
.
text
,
this
.
hintText
,
this
.
style
,
this
.
hid
eText
:
false
,
this
.
obscur
eText
:
false
,
this
.
maxLines
:
1
,
this
.
autofocus
:
false
,
this
.
onChanged
,
...
...
@@ -73,7 +73,9 @@ class InputField extends StatefulWidget {
///
/// When this is set to true, all the characters in the input are replaced by
/// U+2022 BULLET characters (•).
final
bool
hideText
;
///
/// Defaults to false.
final
bool
obscureText
;
/// The maximum number of lines for the text to span, wrapping if necessary.
/// If this is 1 (the default), the text will not wrap, but will scroll
...
...
@@ -81,6 +83,8 @@ class InputField extends StatefulWidget {
final
int
maxLines
;
/// Whether this input field should focus itself if nothing else is already focused.
///
/// Defaults to false.
final
bool
autofocus
;
/// Called when the text being edited changes.
...
...
@@ -130,7 +134,7 @@ class _InputFieldState extends State<InputField> {
value:
value
,
focusKey:
focusKey
,
style:
textStyle
,
hideText:
config
.
hid
eText
,
obscureText:
config
.
obscur
eText
,
maxLines:
config
.
maxLines
,
autofocus:
config
.
autofocus
,
cursorColor:
themeData
.
textSelectionColor
,
...
...
@@ -185,7 +189,7 @@ class InputContainer extends StatefulWidget {
this
.
errorText
,
this
.
style
,
this
.
isDense
:
false
,
this
.
hideDivider
:
fals
e
,
this
.
showDivider
:
tru
e
,
this
.
child
,
})
:
super
(
key:
key
);
...
...
@@ -213,17 +217,25 @@ class InputContainer extends StatefulWidget {
final
TextStyle
style
;
/// Whether the input container is part of a dense form (i.e., uses less vertical space).
///
/// Defaults to false.
final
bool
isDense
;
/// True if the hint and label should be displayed as if the child had the focus.
///
/// Defaults to false.
final
bool
focused
;
/// Should the hint and label be displayed as if no value had been input
/// to the child.
///
/// Defaults to false.
final
bool
isEmpty
;
/// Hide the divider that appears below the child and above the error text.
final
bool
hideDivider
;
/// Whether to show a divider below the child and above the error text.
///
/// Defaults to true.
final
bool
showDivider
;
final
Widget
child
;
...
...
@@ -320,7 +332,7 @@ class _InputContainerState extends State<InputContainer> {
EdgeInsets
margin
=
new
EdgeInsets
.
only
(
bottom:
bottomHeight
-
(
bottomPadding
+
bottomBorder
));
Widget
divider
;
if
(
config
.
hide
Divider
)
{
if
(
!
config
.
show
Divider
)
{
divider
=
new
Container
(
margin:
margin
+
new
EdgeInsets
.
only
(
bottom:
bottomBorder
),
padding:
padding
,
...
...
@@ -419,8 +431,8 @@ class Input extends StatefulWidget {
this
.
hintText
,
this
.
errorText
,
this
.
style
,
this
.
hid
eText
:
false
,
this
.
hideDivider
:
fals
e
,
this
.
obscur
eText
:
false
,
this
.
showDivider
:
tru
e
,
this
.
isDense
:
false
,
this
.
autofocus
:
false
,
this
.
maxLines
:
1
,
...
...
@@ -460,18 +472,26 @@ class Input extends StatefulWidget {
///
/// When this is set to true, all the characters in the input are replaced by
/// U+2022 BULLET characters (•).
final
bool
hideText
;
///
/// Defaults to false.
final
bool
obscureText
;
/// Hide the divider that appears below the child and above the error text.
final
bool
hideDivider
;
/// Whether to show a divider below the child and above the error text.
///
/// Defaults to true.
final
bool
showDivider
;
/// Whether the input field is part of a dense form (i.e., uses less vertical space).
/// If true, [errorText] is not shown.
///
/// Defaults to false.
final
bool
isDense
;
/// Whether this input field should focus itself if nothing else is already focused.
/// If true, the keyboard will open as soon as this input obtains focus. Otherwise,
/// the keyboard is only shown after the user taps the text field.
///
/// Defaults to false.
// See https://github.com/flutter/flutter/issues/7035 for the rationale for this
// keyboard behavior.
final
bool
autofocus
;
...
...
@@ -522,13 +542,13 @@ class _InputState extends State<Input> {
errorText:
config
.
errorText
,
style:
config
.
style
,
isDense:
config
.
isDense
,
hideDivider:
config
.
hide
Divider
,
showDivider:
config
.
show
Divider
,
child:
new
InputField
(
key:
_inputFieldKey
,
focusKey:
focusKey
,
value:
config
.
value
,
style:
config
.
style
,
hideText:
config
.
hid
eText
,
obscureText:
config
.
obscur
eText
,
maxLines:
config
.
maxLines
,
autofocus:
config
.
autofocus
,
keyboardType:
config
.
keyboardType
,
...
...
@@ -622,7 +642,7 @@ class TextField extends FormField<InputValue> {
String
labelText
,
String
hintText
,
TextStyle
style
,
bool
hid
eText:
false
,
bool
obscur
eText:
false
,
bool
isDense:
false
,
bool
autofocus:
false
,
int
maxLines:
1
,
...
...
@@ -643,7 +663,7 @@ class TextField extends FormField<InputValue> {
labelText:
labelText
,
hintText:
hintText
,
style:
style
,
hideText:
hid
eText
,
obscureText:
obscur
eText
,
isDense:
isDense
,
autofocus:
autofocus
,
maxLines:
maxLines
,
...
...
packages/flutter/lib/src/widgets/editable_text.dart
View file @
9573bc14
...
...
@@ -143,7 +143,7 @@ class EditableText extends Scrollable {
Key
key
,
@required
this
.
value
,
this
.
focusKey
,
this
.
hid
eText
:
false
,
this
.
obscur
eText
:
false
,
this
.
style
,
this
.
cursorColor
,
this
.
textScaleFactor
,
...
...
@@ -170,7 +170,9 @@ class EditableText extends Scrollable {
final
GlobalKey
focusKey
;
/// Whether to hide the text being edited (e.g., for passwords).
final
bool
hideText
;
///
/// Defaults to false.
final
bool
obscureText
;
/// The text style to use for the editable text.
final
TextStyle
style
;
...
...
@@ -194,6 +196,8 @@ class EditableText extends Scrollable {
/// Whether this input field should focus itself if nothing else is already focused.
/// If true, the keyboard will open as soon as this input obtains focus. Otherwise,
/// the keyboard is only shown after the user taps the text field.
///
/// Defaults to false.
final
bool
autofocus
;
/// The color to use when painting the selection.
...
...
@@ -469,7 +473,7 @@ class EditableTextState extends ScrollableState<EditableText> implements TextInp
maxLines:
config
.
maxLines
,
selectionColor:
config
.
selectionColor
,
textScaleFactor:
config
.
textScaleFactor
??
MediaQuery
.
of
(
context
).
textScaleFactor
,
hideText:
config
.
hid
eText
,
obscureText:
config
.
obscur
eText
,
onSelectionChanged:
_handleSelectionChanged
,
paintOffset:
scrollOffsetToPixelDelta
(
scrollOffset
),
onPaintOffsetUpdateNeeded:
_handlePaintOffsetUpdateNeeded
...
...
@@ -488,7 +492,7 @@ class _Editable extends LeafRenderObjectWidget {
this
.
maxLines
,
this
.
selectionColor
,
this
.
textScaleFactor
,
this
.
hid
eText
,
this
.
obscur
eText
,
this
.
onSelectionChanged
,
this
.
paintOffset
,
this
.
onPaintOffsetUpdateNeeded
...
...
@@ -501,7 +505,7 @@ class _Editable extends LeafRenderObjectWidget {
final
int
maxLines
;
final
Color
selectionColor
;
final
double
textScaleFactor
;
final
bool
hid
eText
;
final
bool
obscur
eText
;
final
SelectionChangedHandler
onSelectionChanged
;
final
Offset
paintOffset
;
final
RenderEditablePaintOffsetNeededCallback
onPaintOffsetUpdateNeeded
;
...
...
@@ -538,7 +542,7 @@ class _Editable extends LeafRenderObjectWidget {
}
TextSpan
get
_styledTextSpan
{
if
(!
hid
eText
&&
value
.
composing
.
isValid
)
{
if
(!
obscur
eText
&&
value
.
composing
.
isValid
)
{
TextStyle
composingStyle
=
style
.
merge
(
const
TextStyle
(
decoration:
TextDecoration
.
underline
)
);
...
...
@@ -556,7 +560,7 @@ class _Editable extends LeafRenderObjectWidget {
}
String
text
=
value
.
text
;
if
(
hid
eText
)
if
(
obscur
eText
)
text
=
new
String
.
fromCharCodes
(
new
List
<
int
>.
filled
(
text
.
length
,
0x2022
));
return
new
TextSpan
(
style:
style
,
text:
text
);
}
...
...
packages/flutter/test/widgets/input_test.dart
View file @
9573bc14
...
...
@@ -182,7 +182,7 @@ void main() {
await
checkCursorToggle
();
});
testWidgets
(
'
hid
eText control test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'
obscur
eText control test'
,
(
WidgetTester
tester
)
async
{
GlobalKey
inputKey
=
new
GlobalKey
();
Widget
builder
()
{
...
...
@@ -190,7 +190,7 @@ void main() {
child:
new
Material
(
child:
new
Input
(
key:
inputKey
,
hid
eText:
true
,
obscur
eText:
true
,
hintText:
'Placeholder'
)
)
...
...
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