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
a12c22b2
Unverified
Commit
a12c22b2
authored
Dec 04, 2020
by
xubaolin
Committed by
GitHub
Dec 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set [InputDecoration.floatingLabelBehavior] default to null (#70683)
parent
057e8230
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
6 deletions
+62
-6
input_decorator.dart
packages/flutter/lib/src/material/input_decorator.dart
+6
-4
input_decorator_test.dart
packages/flutter/test/material/input_decorator_test.dart
+1
-1
text_field_test.dart
packages/flutter/test/material/text_field_test.dart
+55
-1
No files found.
packages/flutter/lib/src/material/input_decorator.dart
View file @
a12c22b2
...
...
@@ -2518,7 +2518,7 @@ class InputDecoration {
'This feature was deprecated after v1.13.2.'
)
this
.
hasFloatingPlaceholder
=
true
,
this
.
floatingLabelBehavior
=
FloatingLabelBehavior
.
auto
,
this
.
floatingLabelBehavior
,
this
.
isCollapsed
=
false
,
this
.
isDense
,
this
.
contentPadding
,
...
...
@@ -2564,7 +2564,7 @@ class InputDecoration {
'This feature was deprecated after v1.13.2.'
)
this
.
hasFloatingPlaceholder
=
true
,
this
.
floatingLabelBehavior
=
FloatingLabelBehavior
.
auto
,
this
.
floatingLabelBehavior
,
this
.
hintStyle
,
this
.
filled
=
false
,
this
.
fillColor
,
...
...
@@ -2752,9 +2752,9 @@ class InputDecoration {
///
/// When [FloatingLabelBehavior.never] the label will always appear in an empty
/// field in place of the content.
///
/// Defaults to [FloatingLabelBehavior.auto].
/// {@endtemplate}
///
/// If null, [InputDecorationTheme.floatingLabelBehavior] will be used.
final
FloatingLabelBehavior
?
floatingLabelBehavior
;
/// Whether the [InputDecorator.child] is part of a dense form (i.e., uses less vertical
...
...
@@ -3700,6 +3700,8 @@ class InputDecorationTheme with Diagnosticable {
final
bool
hasFloatingPlaceholder
;
/// {@macro flutter.material.inputDecoration.floatingLabelBehavior}
///
/// Defaults to [FloatingLabelBehavior.auto].
final
FloatingLabelBehavior
floatingLabelBehavior
;
/// Whether the input decorator's child is part of a dense form (i.e., uses
...
...
packages/flutter/test/material/input_decorator_test.dart
View file @
a12c22b2
...
...
@@ -3052,7 +3052,7 @@ void main() {
);
expect
(
child
.
toString
(),
"InputDecorator-[<'key'>](decoration: InputDecoration(
floatingLabelBehavior: FloatingLabelBehavior.auto
), baseStyle: TextStyle(<all styles inherited>), isFocused: false, isEmpty: false)"
,
"InputDecorator-[<'key'>](decoration: InputDecoration(), baseStyle: TextStyle(<all styles inherited>), isFocused: false, isEmpty: false)"
,
);
});
...
...
packages/flutter/test/material/text_field_test.dart
View file @
a12c22b2
...
...
@@ -7524,7 +7524,7 @@ void main() {
expect
(
description
,
<
String
>[
'enabled: false'
,
'decoration: InputDecoration(labelText: "foo"
, floatingLabelBehavior: FloatingLabelBehavior.auto
)'
,
'decoration: InputDecoration(labelText: "foo")'
,
'style: TextStyle(inherit: true, color: Color(0xff00ff00))'
,
'autofocus: true'
,
'autocorrect: false'
,
...
...
@@ -8691,4 +8691,58 @@ void main() {
expect
(
inputWidth
,
wideWidth
);
expect
(
cursorRight
,
inputWidth
-
kCaretGap
);
});
// Regressing test for https://github.com/flutter/flutter/issues/70625
testWidgets
(
'TextFields can inherit [FloatingLabelBehaviour] from InputDecorationTheme.'
,
(
WidgetTester
tester
)
async
{
final
FocusNode
focusNode
=
FocusNode
();
Widget
textFieldBuilder
({
FloatingLabelBehavior
behavior
=
FloatingLabelBehavior
.
auto
,
})
{
return
MaterialApp
(
theme:
ThemeData
(
inputDecorationTheme:
InputDecorationTheme
(
floatingLabelBehavior:
behavior
,
),
),
home:
Scaffold
(
body:
TextField
(
focusNode:
focusNode
,
decoration:
const
InputDecoration
(
labelText:
'Label'
,
),
),
),
);
}
await
tester
.
pumpWidget
(
textFieldBuilder
(
behavior:
FloatingLabelBehavior
.
auto
));
// The label will be positioned within the content when unfocused.
expect
(
tester
.
getTopLeft
(
find
.
text
(
'Label'
)).
dy
,
20.0
);
focusNode
.
requestFocus
();
await
tester
.
pumpAndSettle
();
// label animation.
// The label will float above the content when focused.
expect
(
tester
.
getTopLeft
(
find
.
text
(
'Label'
)).
dy
,
12.0
);
focusNode
.
unfocus
();
await
tester
.
pumpAndSettle
();
// label animation.
await
tester
.
pumpWidget
(
textFieldBuilder
(
behavior:
FloatingLabelBehavior
.
never
));
await
tester
.
pumpAndSettle
();
// theme animation.
// The label will be positioned within the content.
expect
(
tester
.
getTopLeft
(
find
.
text
(
'Label'
)).
dy
,
20.0
);
focusNode
.
requestFocus
();
await
tester
.
pumpAndSettle
();
// label animation.
// The label will always be positioned within the content.
expect
(
tester
.
getTopLeft
(
find
.
text
(
'Label'
)).
dy
,
20.0
);
await
tester
.
pumpWidget
(
textFieldBuilder
(
behavior:
FloatingLabelBehavior
.
always
));
await
tester
.
pumpAndSettle
();
// theme animation.
// The label will always float above the content.
expect
(
tester
.
getTopLeft
(
find
.
text
(
'Label'
)).
dy
,
12.0
);
focusNode
.
unfocus
();
await
tester
.
pumpAndSettle
();
// label animation.
// The label will always float above the content.
expect
(
tester
.
getTopLeft
(
find
.
text
(
'Label'
)).
dy
,
12.0
);
});
}
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