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
b9af6551
Unverified
Commit
b9af6551
authored
Jun 19, 2020
by
Justin McCandless
Committed by
GitHub
Jun 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Label unnecessarily ellided (#59807)
parent
65b19560
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
1 deletion
+67
-1
input_decorator.dart
packages/flutter/lib/src/material/input_decorator.dart
+7
-1
input_decorator_test.dart
packages/flutter/test/material/input_decorator_test.dart
+60
-0
No files found.
packages/flutter/lib/src/material/input_decorator.dart
View file @
b9af6551
...
...
@@ -986,9 +986,15 @@ class _RenderDecoration extends RenderBox {
+
contentPadding
.
right
));
// Increase the available width for the label when it is scaled down.
final
double
invertedLabelScale
=
lerpDouble
(
1.00
,
1
/
_kFinalLabelScale
,
decoration
.
floatingLabelProgress
);
final
double
labelWidth
=
math
.
max
(
0.0
,
constraints
.
maxWidth
-
(
_boxSize
(
icon
).
width
+
contentPadding
.
left
+
_boxSize
(
prefixIcon
).
width
+
_boxSize
(
suffixIcon
).
width
+
contentPadding
.
right
));
boxToBaseline
[
label
]
=
_layoutLineBox
(
label
,
boxConstraints
.
copyWith
(
maxWidth:
input
Width
*
invertedLabelScale
),
boxConstraints
.
copyWith
(
maxWidth:
label
Width
*
invertedLabelScale
),
);
boxToBaseline
[
hint
]
=
_layoutLineBox
(
hint
,
...
...
packages/flutter/test/material/input_decorator_test.dart
View file @
b9af6551
...
...
@@ -4158,4 +4158,64 @@ void main() {
expect
(
tester
.
getTopLeft
(
find
.
text
(
hintText
)).
dy
,
topPosition
);
});
testWidgets
(
"InputDecorator label width isn't affected by prefix or suffix"
,
(
WidgetTester
tester
)
async
{
const
String
labelText
=
'My Label'
;
const
String
prefixText
=
'The five boxing wizards jump quickly.'
;
const
String
suffixText
=
'Suffix'
;
Widget
getLabeledInputDecorator
(
bool
showFix
)
{
return
MaterialApp
(
home:
Material
(
child:
Builder
(
builder:
(
BuildContext
context
)
{
return
Theme
(
data:
Theme
.
of
(
context
),
child:
Align
(
alignment:
Alignment
.
topLeft
,
child:
TextField
(
decoration:
InputDecoration
(
icon:
const
Icon
(
Icons
.
assistant
),
prefixText:
showFix
?
prefixText
:
null
,
suffixText:
showFix
?
suffixText
:
null
,
suffixIcon:
const
Icon
(
Icons
.
threesixty
),
labelText:
labelText
,
),
),
),
);
},
),
),
);
}
// Build with no prefix or suffix.
await
tester
.
pumpWidget
(
getLabeledInputDecorator
(
false
));
// Get the width of the label when there is no prefix/suffix.
expect
(
find
.
text
(
prefixText
),
findsNothing
);
expect
(
find
.
text
(
suffixText
),
findsNothing
);
final
double
labelWidth
=
tester
.
getSize
(
find
.
text
(
labelText
)).
width
;
// Build with a prefix and suffix.
await
tester
.
pumpWidget
(
getLabeledInputDecorator
(
true
));
// The prefix and suffix exist but aren't visible. They have not affected
// the width of the label.
expect
(
find
.
text
(
prefixText
),
findsOneWidget
);
expect
(
getOpacity
(
tester
,
prefixText
),
0.0
);
expect
(
find
.
text
(
suffixText
),
findsOneWidget
);
expect
(
getOpacity
(
tester
,
suffixText
),
0.0
);
expect
(
tester
.
getSize
(
find
.
text
(
labelText
)).
width
,
labelWidth
);
// Tap to focus.
await
tester
.
tap
(
find
.
byType
(
TextField
));
await
tester
.
pumpAndSettle
();
// The prefix and suffix are visible, and the label is floating and still
// hasn't had its width affected.
expect
(
tester
.
getSize
(
find
.
text
(
labelText
)).
width
,
labelWidth
);
expect
(
getOpacity
(
tester
,
prefixText
),
1.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