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
6852605c
Commit
6852605c
authored
Jan 16, 2020
by
Josh Burton
Committed by
Flutter GitHub Bot
Jan 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds floatLabelBehavior to InputDecoration (#46115)
parent
c195b771
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
166 additions
and
10 deletions
+166
-10
input_decorator.dart
packages/flutter/lib/src/material/input_decorator.dart
+105
-8
input_decorator_test.dart
packages/flutter/test/material/input_decorator_test.dart
+60
-1
text_field_test.dart
packages/flutter/test/material/text_field_test.dart
+1
-1
No files found.
packages/flutter/lib/src/material/input_decorator.dart
View file @
6852605c
This diff is collapsed.
Click to expand it.
packages/flutter/test/material/input_decorator_test.dart
View file @
6852605c
...
...
@@ -124,6 +124,7 @@ void main() {
),
),
);
await
tester
.
pumpAndSettle
();
// Overall height for this InputDecorator is 56dps:
// 12 - top padding
...
...
@@ -140,6 +141,59 @@ void main() {
expect
(
getBorderBottom
(
tester
),
56.0
);
expect
(
getBorderWeight
(
tester
),
1.0
);
// The label appears within the input when there is no text content
await
tester
.
pumpWidget
(
buildInputDecorator
(
isEmpty:
true
,
// isFocused: false (default)
decoration:
const
InputDecoration
(
labelText:
'label'
,
),
),
);
await
tester
.
pumpAndSettle
();
expect
(
tester
.
getTopLeft
(
find
.
text
(
'label'
)).
dy
,
20.0
);
// The label appears above the input text when there is no content and floatingLabelBehavior is always
await
tester
.
pumpWidget
(
buildInputDecorator
(
isEmpty:
true
,
// isFocused: false (default)
decoration:
const
InputDecoration
(
labelText:
'label'
,
floatingLabelBehavior:
FloatingLabelBehavior
.
always
),
),
);
await
tester
.
pumpAndSettle
();
expect
(
tester
.
getTopLeft
(
find
.
text
(
'label'
)).
dy
,
12.0
);
// The label appears within the input text when there is content and floatingLabelBehavior is never
await
tester
.
pumpWidget
(
buildInputDecorator
(
isEmpty:
false
,
// isFocused: false (default)
decoration:
const
InputDecoration
(
labelText:
'label'
,
floatingLabelBehavior:
FloatingLabelBehavior
.
never
),
),
);
await
tester
.
pumpAndSettle
();
expect
(
tester
.
getTopLeft
(
find
.
text
(
'label'
)).
dy
,
20.0
);
// Overall height for this InputDecorator is 56dps:
// 12 - top padding
// 12 - floating label (ahem font size 16dps * 0.75 = 12)
// 4 - floating label / input text gap
// 16 - input text (ahem font size 16dps)
// 12 - bottom padding
expect
(
tester
.
getTopLeft
(
find
.
text
(
'label'
)).
dy
,
20.0
);
// isFocused: true increases the border's weight from 1.0 to 2.0
// but does not change the overall height.
await
tester
.
pumpWidget
(
...
...
@@ -2476,6 +2530,7 @@ void main() {
isEmpty:
true
,
decoration:
const
InputDecoration
(
border:
OutlineInputBorder
(
borderSide:
BorderSide
.
none
),
// ignore: deprecated_member_use_from_same_package
hasFloatingPlaceholder:
false
,
labelText:
'label'
,
),
...
...
@@ -2500,6 +2555,7 @@ void main() {
// isFocused: false (default)
decoration:
const
InputDecoration
(
border:
OutlineInputBorder
(
borderSide:
BorderSide
.
none
),
// ignore: deprecated_member_use_from_same_package
hasFloatingPlaceholder:
false
,
labelText:
'label'
,
),
...
...
@@ -2679,7 +2735,7 @@ void main() {
);
expect
(
child
.
toString
(),
"InputDecorator-[<'key'>](decoration: InputDecoration(), baseStyle: TextStyle(<all styles inherited>), isFocused: false, isEmpty: false)"
,
"InputDecorator-[<'key'>](decoration: InputDecoration(
floatingLabelBehavior: FloatingLabelBehavior.auto
), baseStyle: TextStyle(<all styles inherited>), isFocused: false, isEmpty: false)"
,
);
});
...
...
@@ -3509,7 +3565,9 @@ void main() {
helperMaxLines:
6
,
hintStyle:
TextStyle
(),
errorMaxLines:
5
,
// ignore: deprecated_member_use_from_same_package
hasFloatingPlaceholder:
false
,
floatingLabelBehavior:
FloatingLabelBehavior
.
never
,
contentPadding:
EdgeInsetsDirectional
.
only
(
start:
40.0
,
top:
12.0
,
bottom:
12.0
),
prefixStyle:
TextStyle
(),
suffixStyle:
TextStyle
(),
...
...
@@ -3535,6 +3593,7 @@ void main() {
'hintStyle: TextStyle(<all styles inherited>)'
,
'errorMaxLines: 5'
,
'hasFloatingPlaceholder: false'
,
'floatingLabelBehavior: FloatingLabelBehavior.never'
,
'contentPadding: EdgeInsetsDirectional(40.0, 12.0, 0.0, 12.0)'
,
'prefixStyle: TextStyle(<all styles inherited>)'
,
'suffixStyle: TextStyle(<all styles inherited>)'
,
...
...
packages/flutter/test/material/text_field_test.dart
View file @
6852605c
...
...
@@ -6565,7 +6565,7 @@ void main() {
expect
(
description
,
<
String
>[
'enabled: false'
,
'decoration: InputDecoration(labelText: "foo")'
,
'decoration: InputDecoration(labelText: "foo"
, floatingLabelBehavior: FloatingLabelBehavior.auto
)'
,
'style: TextStyle(inherit: true, color: Color(0xff00ff00))'
,
'autofocus: true'
,
'autocorrect: false'
,
...
...
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