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
8cd892b3
Unverified
Commit
8cd892b3
authored
Nov 06, 2019
by
Gary Qian
Committed by
GitHub
Nov 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use alphabetic baselines for layout of InputDecorator (#44029)
parent
2110dfe0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
1 deletion
+50
-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
+43
-0
No files found.
packages/flutter/lib/src/material/input_decorator.dart
View file @
8cd892b3
...
...
@@ -907,7 +907,13 @@ class _RenderDecoration extends RenderBox {
return
0.0
;
}
box
.
layout
(
constraints
,
parentUsesSize:
true
);
final
double
baseline
=
box
.
getDistanceToBaseline
(
textBaseline
);
// Since internally, all layout is performed against the alphabetic baseline,
// (eg, ascents/descents are all relative to alphabetic, even if the font is
// an ideographic or hanging font), we should always obtain the reference
// baseline from the alphabetic baseline. The ideographic baseline is for
// use post-layout and is derived from the alphabetic baseline combined with
// the font metrics.
final
double
baseline
=
box
.
getDistanceToBaseline
(
TextBaseline
.
alphabetic
);
assert
(
baseline
!=
null
&&
baseline
>=
0.0
);
return
baseline
;
}
...
...
packages/flutter/test/material/input_decorator_test.dart
View file @
8cd892b3
...
...
@@ -3551,4 +3551,47 @@ void main() {
'alignLabelWithHint: true'
,
]);
});
testWidgets
(
'uses alphabetic baseline for CJK layout'
,
(
WidgetTester
tester
)
async
{
await
tester
.
binding
.
setLocale
(
'zh'
,
'CN'
);
final
Typography
typography
=
Typography
();
final
FocusNode
focusNode
=
FocusNode
();
final
TextEditingController
controller
=
TextEditingController
();
// The dense theme uses ideographic baselines
Widget
buildFrame
(
bool
alignLabelWithHint
)
{
return
MaterialApp
(
theme:
ThemeData
(
textTheme:
typography
.
dense
,
),
home:
Material
(
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
TextField
(
controller:
controller
,
focusNode:
focusNode
,
decoration:
InputDecoration
(
labelText:
'label'
,
alignLabelWithHint:
alignLabelWithHint
,
hintText:
'hint'
,
hintStyle:
const
TextStyle
(
fontFamily:
'Cough'
,
),
),
),
),
),
);
}
await
tester
.
pumpWidget
(
buildFrame
(
true
));
await
tester
.
pumpAndSettle
();
// These numbers should be the values from using alphabetic baselines:
// Ideographic (incorrect) value is 31.299999713897705
expect
(
tester
.
getTopLeft
(
find
.
text
(
'hint'
)).
dy
,
28.75
);
// Ideographic (incorrect) value is 50.299999713897705
expect
(
tester
.
getBottomLeft
(
find
.
text
(
'hint'
)).
dy
,
47.75
);
});
}
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