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
6fbe39e2
Commit
6fbe39e2
authored
Dec 01, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #645 from abarth/hide_text
Add input#hideText
parents
3b278c56
179d191e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
1 deletion
+34
-1
input.dart
packages/flutter/lib/src/material/input.dart
+3
-0
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+8
-1
input_test.dart
packages/unit/test/widget/input_test.dart
+23
-0
No files found.
packages/flutter/lib/src/material/input.dart
View file @
6fbe39e2
...
...
@@ -21,6 +21,7 @@ class Input extends Scrollable {
GlobalKey
key
,
this
.
initialValue
:
''
,
this
.
placeholder
,
this
.
hideText
:
false
,
this
.
onChanged
,
this
.
keyboardType
:
KeyboardType
.
TEXT
,
this
.
onSubmitted
...
...
@@ -33,6 +34,7 @@ class Input extends Scrollable {
final
String
initialValue
;
final
KeyboardType
keyboardType
;
final
String
placeholder
;
final
bool
hideText
;
final
ValueChanged
<
String
>
onChanged
;
final
ValueChanged
<
String
>
onSubmitted
;
...
...
@@ -110,6 +112,7 @@ class InputState extends ScrollableState<Input> {
value:
_editableValue
,
focused:
focused
,
style:
textStyle
,
hideText:
config
.
hideText
,
cursorColor:
cursorColor
,
onContentSizeChanged:
_handleContentSizeChanged
,
scrollOffset:
scrollOffsetVector
...
...
packages/flutter/lib/src/widgets/editable_text.dart
View file @
6fbe39e2
...
...
@@ -144,6 +144,7 @@ class EditableText extends StatefulComponent {
Key
key
,
this
.
value
,
this
.
focused
:
false
,
this
.
hideText
:
false
,
this
.
style
,
this
.
cursorColor
,
this
.
onContentSizeChanged
,
...
...
@@ -152,6 +153,7 @@ class EditableText extends StatefulComponent {
final
EditableString
value
;
final
bool
focused
;
final
bool
hideText
;
final
TextStyle
style
;
final
Color
cursorColor
;
final
SizeChangedCallback
onContentSizeChanged
;
...
...
@@ -216,6 +218,7 @@ class EditableTextState extends State<EditableText> {
style:
config
.
style
,
cursorColor:
config
.
cursorColor
,
showCursor:
_showCursor
,
hideText:
config
.
hideText
,
onContentSizeChanged:
config
.
onContentSizeChanged
,
scrollOffset:
config
.
scrollOffset
)
...
...
@@ -232,6 +235,7 @@ class _EditableTextWidget extends LeafRenderObjectWidget {
this
.
style
,
this
.
cursorColor
,
this
.
showCursor
,
this
.
hideText
,
this
.
onContentSizeChanged
,
this
.
scrollOffset
})
:
super
(
key:
key
);
...
...
@@ -240,6 +244,7 @@ class _EditableTextWidget extends LeafRenderObjectWidget {
final
TextStyle
style
;
final
Color
cursorColor
;
final
bool
showCursor
;
final
bool
hideText
;
final
SizeChangedCallback
onContentSizeChanged
;
final
Offset
scrollOffset
;
...
...
@@ -264,7 +269,7 @@ class _EditableTextWidget extends LeafRenderObjectWidget {
// Construct a TextSpan that renders the EditableString using the chosen style.
TextSpan
_buildTextSpan
()
{
if
(
value
.
composing
.
isValid
)
{
if
(
!
hideText
&&
value
.
composing
.
isValid
)
{
TextStyle
composingStyle
=
style
.
merge
(
const
TextStyle
(
decoration:
underline
)
);
...
...
@@ -279,6 +284,8 @@ class _EditableTextWidget extends LeafRenderObjectWidget {
}
String
text
=
value
.
text
;
if
(
hideText
)
text
=
new
String
.
fromCharCodes
(
new
List
<
int
>.
filled
(
text
.
length
,
0x2022
));
return
new
StyledTextSpan
(
style
,
<
TextSpan
>[
new
PlainTextSpan
(
text
.
isEmpty
?
_kZeroWidthSpace
:
text
)
]);
...
...
packages/unit/test/widget/input_test.dart
View file @
6fbe39e2
...
...
@@ -138,4 +138,27 @@ void main() {
expect
(
input
.
editableValue
.
selection
.
start
,
equals
(
0
));
});
});
test
(
'hideText control test'
,
()
{
testWidgets
((
WidgetTester
tester
)
{
GlobalKey
inputKey
=
new
GlobalKey
();
Widget
builder
()
{
return
new
Center
(
child:
new
Input
(
key:
inputKey
,
hideText:
true
,
placeholder:
'Placeholder'
)
);
}
tester
.
pumpWidget
(
builder
());
const
String
testValue
=
'ABC'
;
mockKeyboard
.
client
.
commitText
(
testValue
,
testValue
.
length
);
tester
.
pump
();
});
});
}
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