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
71c374af
Commit
71c374af
authored
Jul 18, 2017
by
Jason Simmons
Committed by
GitHub
Jul 18, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a flag that controls autocorrect on text fields (#11180)
See
https://github.com/flutter/flutter/issues/11168
parent
898c19d7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
4 deletions
+41
-4
text_field.dart
packages/flutter/lib/src/material/text_field.dart
+12
-1
text_form_field.dart
packages/flutter/lib/src/material/text_form_field.dart
+3
-0
text_input.dart
packages/flutter/lib/src/services/text_input.dart
+10
-2
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+13
-1
text_input_test.dart
packages/flutter/test/services/text_input_test.dart
+3
-0
No files found.
packages/flutter/lib/src/material/text_field.dart
View file @
71c374af
...
...
@@ -68,7 +68,8 @@ class TextField extends StatefulWidget {
/// the number of lines. By default, it is 1, meaning this is a single-line
/// text field. If it is not null, it must be greater than zero.
///
/// The [keyboardType], [autofocus], and [obscureText] arguments must not be null.
/// The [keyboardType], [autofocus], [obscureText], and [autocorrect] arguments
/// must not be null.
const
TextField
({
Key
key
,
this
.
controller
,
...
...
@@ -79,6 +80,7 @@ class TextField extends StatefulWidget {
this
.
textAlign
,
this
.
autofocus
:
false
,
this
.
obscureText
:
false
,
this
.
autocorrect
:
true
,
this
.
maxLines
:
1
,
this
.
onChanged
,
this
.
onSubmitted
,
...
...
@@ -86,6 +88,7 @@ class TextField extends StatefulWidget {
})
:
assert
(
keyboardType
!=
null
),
assert
(
autofocus
!=
null
),
assert
(
obscureText
!=
null
),
assert
(
autocorrect
!=
null
),
assert
(
maxLines
==
null
||
maxLines
>
0
),
super
(
key:
key
);
...
...
@@ -142,6 +145,11 @@ class TextField extends StatefulWidget {
/// Defaults to false. Cannot be null.
final
bool
obscureText
;
/// Whether to enable autocorrection.
///
/// Defaults to true. Cannot be null.
final
bool
autocorrect
;
/// 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
...
...
@@ -181,6 +189,8 @@ class TextField extends StatefulWidget {
description
.
add
(
'autofocus:
$autofocus
'
);
if
(
obscureText
)
description
.
add
(
'obscureText:
$obscureText
'
);
if
(
autocorrect
)
description
.
add
(
'autocorrect:
$autocorrect
'
);
if
(
maxLines
!=
1
)
description
.
add
(
'maxLines:
$maxLines
'
);
}
...
...
@@ -243,6 +253,7 @@ class _TextFieldState extends State<TextField> {
textAlign:
widget
.
textAlign
,
autofocus:
widget
.
autofocus
,
obscureText:
widget
.
obscureText
,
autocorrect:
widget
.
autocorrect
,
maxLines:
widget
.
maxLines
,
cursorColor:
themeData
.
textSelectionColor
,
selectionColor:
themeData
.
textSelectionColor
,
...
...
packages/flutter/lib/src/material/text_form_field.dart
View file @
71c374af
...
...
@@ -41,6 +41,7 @@ class TextFormField extends FormField<String> {
TextStyle
style
,
bool
autofocus:
false
,
bool
obscureText:
false
,
bool
autocorrect:
true
,
int
maxLines:
1
,
FormFieldSetter
<
String
>
onSaved
,
FormFieldValidator
<
String
>
validator
,
...
...
@@ -48,6 +49,7 @@ class TextFormField extends FormField<String> {
})
:
assert
(
keyboardType
!=
null
),
assert
(
autofocus
!=
null
),
assert
(
obscureText
!=
null
),
assert
(
autocorrect
!=
null
),
assert
(
maxLines
==
null
||
maxLines
>
0
),
super
(
key:
key
,
...
...
@@ -63,6 +65,7 @@ class TextFormField extends FormField<String> {
style:
style
,
autofocus:
autofocus
,
obscureText:
obscureText
,
autocorrect:
autocorrect
,
maxLines:
maxLines
,
onChanged:
field
.
onChanged
,
inputFormatters:
inputFormatters
,
...
...
packages/flutter/lib/src/services/text_input.dart
View file @
71c374af
...
...
@@ -67,13 +67,15 @@ enum TextInputAction {
class
TextInputConfiguration
{
/// Creates configuration information for a text input control.
///
/// The [inputType]
and [obscureTex
t] arguments must not be null.
/// The [inputType]
, [obscureText], and [autocorrec
t] arguments must not be null.
const
TextInputConfiguration
({
this
.
inputType
:
TextInputType
.
text
,
this
.
obscureText
:
false
,
this
.
autocorrect
:
true
,
this
.
actionLabel
,
})
:
assert
(
inputType
!=
null
),
assert
(
obscureText
!=
null
);
assert
(
obscureText
!=
null
),
assert
(
autocorrect
!=
null
);
/// The type of information for which to optimize the text input control.
final
TextInputType
inputType
;
...
...
@@ -83,6 +85,11 @@ class TextInputConfiguration {
/// Defaults to false.
final
bool
obscureText
;
/// Whether to enable autocorrection.
///
/// Defaults to true.
final
bool
autocorrect
;
/// What text to display in the text input control's action button.
final
String
actionLabel
;
...
...
@@ -91,6 +98,7 @@ class TextInputConfiguration {
return
<
String
,
dynamic
>{
'inputType'
:
inputType
.
toString
(),
'obscureText'
:
obscureText
,
'autocorrect'
:
autocorrect
,
'actionLabel'
:
actionLabel
,
};
}
...
...
packages/flutter/lib/src/widgets/editable_text.dart
View file @
71c374af
...
...
@@ -147,6 +147,7 @@ class EditableText extends StatefulWidget {
@required
this
.
controller
,
@required
this
.
focusNode
,
this
.
obscureText
:
false
,
this
.
autocorrect
:
true
,
@required
this
.
style
,
@required
this
.
cursorColor
,
this
.
textAlign
,
...
...
@@ -163,6 +164,7 @@ class EditableText extends StatefulWidget {
})
:
assert
(
controller
!=
null
),
assert
(
focusNode
!=
null
),
assert
(
obscureText
!=
null
),
assert
(
autocorrect
!=
null
),
assert
(
style
!=
null
),
assert
(
cursorColor
!=
null
),
assert
(
maxLines
==
null
||
maxLines
>
0
),
...
...
@@ -186,6 +188,11 @@ class EditableText extends StatefulWidget {
/// Defaults to false.
final
bool
obscureText
;
/// Whether to enable autocorrection.
///
/// Defaults to true.
final
bool
autocorrect
;
/// The text style to use for the editable text.
final
TextStyle
style
;
...
...
@@ -253,6 +260,8 @@ class EditableText extends StatefulWidget {
description
.
add
(
'focusNode:
$focusNode
'
);
if
(
obscureText
!=
false
)
description
.
add
(
'obscureText:
$obscureText
'
);
if
(
autocorrect
!=
true
)
description
.
add
(
'autocorrect:
$autocorrect
'
);
description
.
add
(
'
${style.toString().split("\n").join(", ")}
'
);
if
(
textAlign
!=
null
)
description
.
add
(
'
$textAlign
'
);
...
...
@@ -388,7 +397,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
if
(!
_hasInputConnection
)
{
final
TextEditingValue
localValue
=
_value
;
_lastKnownRemoteTextEditingValue
=
localValue
;
_textInputConnection
=
TextInput
.
attach
(
this
,
new
TextInputConfiguration
(
inputType:
widget
.
keyboardType
,
obscureText:
widget
.
obscureText
))
_textInputConnection
=
TextInput
.
attach
(
this
,
new
TextInputConfiguration
(
inputType:
widget
.
keyboardType
,
obscureText:
widget
.
obscureText
,
autocorrect:
widget
.
autocorrect
))
..
setEditingState
(
localValue
);
}
_textInputConnection
.
show
();
...
...
@@ -578,6 +587,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
textScaleFactor:
widget
.
textScaleFactor
??
MediaQuery
.
of
(
context
,
nullOk:
true
)?.
textScaleFactor
??
1.0
,
textAlign:
widget
.
textAlign
,
obscureText:
widget
.
obscureText
,
autocorrect:
widget
.
autocorrect
,
offset:
offset
,
onSelectionChanged:
_handleSelectionChanged
,
onCaretChanged:
_handleCaretChanged
,
...
...
@@ -600,6 +610,7 @@ class _Editable extends LeafRenderObjectWidget {
this
.
textScaleFactor
,
this
.
textAlign
,
this
.
obscureText
,
this
.
autocorrect
,
this
.
offset
,
this
.
onSelectionChanged
,
this
.
onCaretChanged
,
...
...
@@ -614,6 +625,7 @@ class _Editable extends LeafRenderObjectWidget {
final
double
textScaleFactor
;
final
TextAlign
textAlign
;
final
bool
obscureText
;
final
bool
autocorrect
;
final
ViewportOffset
offset
;
final
SelectionChangedHandler
onSelectionChanged
;
final
CaretChangedHandler
onCaretChanged
;
...
...
packages/flutter/test/services/text_input_test.dart
View file @
71c374af
...
...
@@ -11,6 +11,7 @@ void main() {
final
TextInputConfiguration
configuration
=
const
TextInputConfiguration
();
expect
(
configuration
.
inputType
,
TextInputType
.
text
);
expect
(
configuration
.
obscureText
,
false
);
expect
(
configuration
.
autocorrect
,
true
);
expect
(
configuration
.
actionLabel
,
null
);
});
...
...
@@ -18,11 +19,13 @@ void main() {
final
TextInputConfiguration
configuration
=
const
TextInputConfiguration
(
inputType:
TextInputType
.
number
,
obscureText:
true
,
autocorrect:
false
,
actionLabel:
'xyzzy'
);
final
Map
<
String
,
dynamic
>
json
=
configuration
.
toJSON
();
expect
(
json
[
'inputType'
],
'TextInputType.number'
);
expect
(
json
[
'obscureText'
],
true
);
expect
(
json
[
'autocorrect'
],
false
);
expect
(
json
[
'actionLabel'
],
'xyzzy'
);
});
});
...
...
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