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
43ce3fd9
Unverified
Commit
43ce3fd9
authored
Apr 28, 2020
by
Justin McCandless
Committed by
GitHub
Apr 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TextField enabled fix (#55775)
parent
f7ad30b7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
4 deletions
+98
-4
text_field.dart
packages/flutter/lib/src/material/text_field.dart
+1
-1
text_form_field.dart
packages/flutter/lib/src/material/text_form_field.dart
+3
-3
text_field_test.dart
packages/flutter/test/material/text_field_test.dart
+46
-0
text_form_field_test.dart
packages/flutter/test/material/text_form_field_test.dart
+48
-0
No files found.
packages/flutter/lib/src/material/text_field.dart
View file @
43ce3fd9
...
...
@@ -802,7 +802,7 @@ class _TextFieldState extends State<TextField> implements TextSelectionGestureDe
final
InputDecoration
effectiveDecoration
=
(
widget
.
decoration
??
const
InputDecoration
())
.
applyDefaults
(
themeData
.
inputDecorationTheme
)
.
copyWith
(
enabled:
widget
.
e
nabled
,
enabled:
_isE
nabled
,
hintMaxLines:
widget
.
decoration
?.
hintMaxLines
??
widget
.
maxLines
,
);
...
...
packages/flutter/lib/src/material/text_form_field.dart
View file @
43ce3fd9
...
...
@@ -165,7 +165,7 @@ class TextFormField extends FormField<String> {
FormFieldSetter
<
String
>
onSaved
,
FormFieldValidator
<
String
>
validator
,
List
<
TextInputFormatter
>
inputFormatters
,
bool
enabled
=
true
,
bool
enabled
,
double
cursorWidth
=
2.0
,
Radius
cursorRadius
,
Color
cursorColor
,
...
...
@@ -205,7 +205,7 @@ class TextFormField extends FormField<String> {
onSaved:
onSaved
,
validator:
validator
,
autovalidate:
autovalidate
,
enabled:
enabled
,
enabled:
enabled
??
decoration
?.
enabled
??
true
,
builder:
(
FormFieldState
<
String
>
field
)
{
final
_TextFormFieldState
state
=
field
as
_TextFormFieldState
;
final
InputDecoration
effectiveDecoration
=
(
decoration
??
const
InputDecoration
())
...
...
@@ -248,7 +248,7 @@ class TextFormField extends FormField<String> {
onEditingComplete:
onEditingComplete
,
onSubmitted:
onFieldSubmitted
,
inputFormatters:
inputFormatters
,
enabled:
enabled
,
enabled:
enabled
??
decoration
?.
enabled
??
true
,
cursorWidth:
cursorWidth
,
cursorRadius:
cursorRadius
,
cursorColor:
cursorColor
,
...
...
packages/flutter/test/material/text_field_test.dart
View file @
43ce3fd9
...
...
@@ -3597,6 +3597,52 @@ void main() {
semantics
.
dispose
();
});
testWidgets
(
'Disabled text field hides helper and counter'
,
(
WidgetTester
tester
)
async
{
const
String
helperText
=
'helper text'
;
const
String
counterText
=
'counter text'
;
const
String
errorText
=
'error text'
;
Widget
buildFrame
(
bool
enabled
,
bool
hasError
)
{
return
MaterialApp
(
home:
Material
(
child:
Center
(
child:
TextField
(
decoration:
InputDecoration
(
labelText:
'label text'
,
helperText:
helperText
,
counterText:
counterText
,
errorText:
hasError
?
errorText
:
null
,
enabled:
enabled
,
),
),
),
),
);
}
await
tester
.
pumpWidget
(
buildFrame
(
true
,
false
));
Text
helperWidget
=
tester
.
widget
(
find
.
text
(
helperText
));
Text
counterWidget
=
tester
.
widget
(
find
.
text
(
counterText
));
expect
(
helperWidget
.
style
.
color
,
isNot
(
equals
(
Colors
.
transparent
)));
expect
(
counterWidget
.
style
.
color
,
isNot
(
equals
(
Colors
.
transparent
)));
await
tester
.
pumpWidget
(
buildFrame
(
true
,
true
));
counterWidget
=
tester
.
widget
(
find
.
text
(
counterText
));
Text
errorWidget
=
tester
.
widget
(
find
.
text
(
errorText
));
expect
(
helperWidget
.
style
.
color
,
isNot
(
equals
(
Colors
.
transparent
)));
expect
(
errorWidget
.
style
.
color
,
isNot
(
equals
(
Colors
.
transparent
)));
// When enabled is false, the helper/error and counter are not visible.
await
tester
.
pumpWidget
(
buildFrame
(
false
,
false
));
helperWidget
=
tester
.
widget
(
find
.
text
(
helperText
));
counterWidget
=
tester
.
widget
(
find
.
text
(
counterText
));
expect
(
helperWidget
.
style
.
color
,
equals
(
Colors
.
transparent
));
expect
(
counterWidget
.
style
.
color
,
equals
(
Colors
.
transparent
));
await
tester
.
pumpWidget
(
buildFrame
(
false
,
true
));
errorWidget
=
tester
.
widget
(
find
.
text
(
errorText
));
counterWidget
=
tester
.
widget
(
find
.
text
(
counterText
));
expect
(
counterWidget
.
style
.
color
,
equals
(
Colors
.
transparent
));
expect
(
errorWidget
.
style
.
color
,
equals
(
Colors
.
transparent
));
});
testWidgets
(
'currentValueLength/maxValueLength are in the tree'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
final
TextEditingController
controller
=
TextEditingController
();
...
...
packages/flutter/test/material/text_form_field_test.dart
View file @
43ce3fd9
...
...
@@ -240,6 +240,54 @@ void main() {
expect
(
_validateCalled
,
2
);
});
testWidgets
(
'Disabled field hides helper and counter'
,
(
WidgetTester
tester
)
async
{
const
String
helperText
=
'helper text'
;
const
String
counterText
=
'counter text'
;
const
String
errorText
=
'error text'
;
Widget
buildFrame
(
bool
enabled
,
bool
hasError
)
{
return
MaterialApp
(
home:
Material
(
child:
Center
(
child:
TextFormField
(
decoration:
InputDecoration
(
labelText:
'label text'
,
helperText:
helperText
,
counterText:
counterText
,
errorText:
hasError
?
errorText
:
null
,
enabled:
enabled
,
),
),
),
),
);
}
// When enabled is true, the helper/error and counter are visible.
await
tester
.
pumpWidget
(
buildFrame
(
true
,
false
));
Text
helperWidget
=
tester
.
widget
(
find
.
text
(
helperText
));
Text
counterWidget
=
tester
.
widget
(
find
.
text
(
counterText
));
expect
(
helperWidget
.
style
.
color
,
isNot
(
equals
(
Colors
.
transparent
)));
expect
(
counterWidget
.
style
.
color
,
isNot
(
equals
(
Colors
.
transparent
)));
await
tester
.
pumpWidget
(
buildFrame
(
true
,
true
));
counterWidget
=
tester
.
widget
(
find
.
text
(
counterText
));
Text
errorWidget
=
tester
.
widget
(
find
.
text
(
errorText
));
expect
(
helperWidget
.
style
.
color
,
isNot
(
equals
(
Colors
.
transparent
)));
expect
(
errorWidget
.
style
.
color
,
isNot
(
equals
(
Colors
.
transparent
)));
// When enabled is false, the helper/error and counter are not visible.
await
tester
.
pumpWidget
(
buildFrame
(
false
,
false
));
helperWidget
=
tester
.
widget
(
find
.
text
(
helperText
));
counterWidget
=
tester
.
widget
(
find
.
text
(
counterText
));
expect
(
helperWidget
.
style
.
color
,
equals
(
Colors
.
transparent
));
expect
(
counterWidget
.
style
.
color
,
equals
(
Colors
.
transparent
));
await
tester
.
pumpWidget
(
buildFrame
(
false
,
true
));
errorWidget
=
tester
.
widget
(
find
.
text
(
errorText
));
counterWidget
=
tester
.
widget
(
find
.
text
(
counterText
));
expect
(
counterWidget
.
style
.
color
,
equals
(
Colors
.
transparent
));
expect
(
errorWidget
.
style
.
color
,
equals
(
Colors
.
transparent
));
});
testWidgets
(
'passing a buildCounter shows returned widget'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Material
(
...
...
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