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
bb59993a
Unverified
Commit
bb59993a
authored
Sep 09, 2020
by
Anatoly Pulyaevskiy
Committed by
GitHub
Sep 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose 3 new methods with text metrics in RenderParagraph (#65150)
parent
0d8de393
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
1 deletion
+23
-1
text_painter.dart
packages/flutter/lib/src/painting/text_painter.dart
+3
-1
paragraph.dart
packages/flutter/lib/src/rendering/paragraph.dart
+9
-0
paragraph_test.dart
packages/flutter/test/rendering/paragraph_test.dart
+11
-0
No files found.
packages/flutter/lib/src/painting/text_painter.dart
View file @
bb59993a
...
@@ -784,7 +784,9 @@ class TextPainter {
...
@@ -784,7 +784,9 @@ class TextPainter {
return
_caretMetrics
.
offset
;
return
_caretMetrics
.
offset
;
}
}
/// Returns the tight bounded height of the glyph at the given [position].
/// {@template flutter.painting.textPainter.getFullHeightForCaret}
/// Returns the strut bounded height of the glyph at the given `position`.
/// {@endtemplate}
///
///
/// Valid only after [layout] has been called.
/// Valid only after [layout] has been called.
double
?
getFullHeightForCaret
(
TextPosition
position
,
Rect
caretPrototype
)
{
double
?
getFullHeightForCaret
(
TextPosition
position
,
Rect
caretPrototype
)
{
...
...
packages/flutter/lib/src/rendering/paragraph.dart
View file @
bb59993a
...
@@ -744,6 +744,15 @@ class RenderParagraph extends RenderBox
...
@@ -744,6 +744,15 @@ class RenderParagraph extends RenderBox
return
_textPainter
.
getOffsetForCaret
(
position
,
caretPrototype
);
return
_textPainter
.
getOffsetForCaret
(
position
,
caretPrototype
);
}
}
/// {@macro flutter.painting.textPainter.getFullHeightForCaret}
///
/// Valid only after [layout].
double
?
getFullHeightForCaret
(
TextPosition
position
)
{
assert
(!
debugNeedsLayout
);
_layoutTextWithConstraints
(
constraints
);
return
_textPainter
.
getFullHeightForCaret
(
position
,
Rect
.
zero
);
}
/// Returns a list of rects that bound the given selection.
/// Returns a list of rects that bound the given selection.
///
///
/// A given selection might have more than one rect if this text painter
/// A given selection might have more than one rect if this text painter
...
...
packages/flutter/test/rendering/paragraph_test.dart
View file @
bb59993a
...
@@ -36,6 +36,17 @@ void main() {
...
@@ -36,6 +36,17 @@ void main() {
expect
(
offset50
.
dy
,
greaterThan
(
offset5
.
dy
));
expect
(
offset50
.
dy
,
greaterThan
(
offset5
.
dy
));
});
});
test
(
'getFullHeightForCaret control test'
,
()
{
final
RenderParagraph
paragraph
=
RenderParagraph
(
const
TextSpan
(
text:
_kText
,
style:
TextStyle
(
fontSize:
10.0
)),
textDirection:
TextDirection
.
ltr
,
);
layout
(
paragraph
);
final
double
height5
=
paragraph
.
getFullHeightForCaret
(
const
TextPosition
(
offset:
5
));
expect
(
height5
,
equals
(
10.0
));
});
test
(
'getPositionForOffset control test'
,
()
{
test
(
'getPositionForOffset control test'
,
()
{
final
RenderParagraph
paragraph
=
RenderParagraph
(
final
RenderParagraph
paragraph
=
RenderParagraph
(
const
TextSpan
(
text:
_kText
),
const
TextSpan
(
text:
_kText
),
...
...
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