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
53a2ec1b
Unverified
Commit
53a2ec1b
authored
Nov 14, 2017
by
Hans Muller
Committed by
GitHub
Nov 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for baseline alignment to TextField (RenderEditable) (#13006)
parent
736b414f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
0 deletions
+58
-0
editable.dart
packages/flutter/lib/src/rendering/editable.dart
+6
-0
text_field_test.dart
packages/flutter/test/material/text_field_test.dart
+52
-0
No files found.
packages/flutter/lib/src/rendering/editable.dart
View file @
53a2ec1b
...
...
@@ -490,6 +490,12 @@ class RenderEditable extends RenderBox {
return
_preferredHeight
(
width
);
}
@override
double
computeDistanceToActualBaseline
(
TextBaseline
baseline
)
{
_layoutText
(
constraints
.
maxWidth
);
return
_textPainter
.
computeDistanceToActualBaseline
(
baseline
);
}
@override
bool
hitTestSelf
(
Offset
position
)
=>
true
;
...
...
packages/flutter/test/material/text_field_test.dart
View file @
53a2ec1b
...
...
@@ -1690,4 +1690,56 @@ void main() {
// Confirm that the selection was updated.
expect
(
controller
.
selection
.
baseOffset
,
0
);
});
testWidgets
(
'TextField baseline alignment'
,
(
WidgetTester
tester
)
async
{
final
TextEditingController
controllerA
=
new
TextEditingController
(
text:
'A'
);
final
TextEditingController
controllerB
=
new
TextEditingController
(
text:
'B'
);
final
Key
keyA
=
new
UniqueKey
();
final
Key
keyB
=
new
UniqueKey
();
await
tester
.
pumpWidget
(
overlay
(
child:
new
Row
(
crossAxisAlignment:
CrossAxisAlignment
.
baseline
,
textBaseline:
TextBaseline
.
alphabetic
,
children:
<
Widget
>[
new
Expanded
(
child:
new
TextField
(
key:
keyA
,
decoration:
null
,
controller:
controllerA
,
style:
const
TextStyle
(
fontSize:
10.0
),
)
),
const
Text
(
'abc'
,
style:
const
TextStyle
(
fontSize:
20.0
),
),
new
Expanded
(
child:
new
TextField
(
key:
keyB
,
decoration:
null
,
controller:
controllerB
,
style:
const
TextStyle
(
fontSize:
30.0
),
),
),
],
),
),
);
// The Ahem font extends 0.2 * fontSize below the baseline.
// So the three row elements line up like this:
//
// A abc B
// --------- baseline
// 2 4 6 space below the baseline = 0.2 * fontSize
// --------- rowBottomY
final
double
rowBottomY
=
tester
.
getBottomLeft
(
find
.
byType
(
Row
)).
dy
;
expect
(
tester
.
getBottomLeft
(
find
.
byKey
(
keyA
)).
dy
,
rowBottomY
-
4.0
);
expect
(
tester
.
getBottomLeft
(
find
.
text
(
'abc'
)).
dy
,
rowBottomY
-
2.0
);
expect
(
tester
.
getBottomLeft
(
find
.
byKey
(
keyB
)).
dy
,
rowBottomY
);
});
}
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